Skip to content

Instantly share code, notes, and snippets.

@Siddhant
Created June 25, 2012 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Siddhant/2991221 to your computer and use it in GitHub Desktop.
Save Siddhant/2991221 to your computer and use it in GitHub Desktop.
siddhant@siddhant-laptop:~/perl6 code$ cat class-point
use v6;
class Point {
has $.x;
has $.y;
has $.d;
method distance_from_origin {
$!d = sqrt($!x**2 + $!y**2);
}
}
my $A = Point.new;
$A.x = 1;
$A.y = 2;
say $A.distance_from_origin;
siddhant@siddhant-laptop:~/perl6 code$ perl6 class-point
Cannot assign to a readonly variable or a value
in block <anon> at class-point:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment