Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment