Created
June 25, 2012 21:02
-
-
Save Siddhant/2991221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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