Created
July 2, 2017 20:46
-
-
Save ufobat/92a4eead04bbfae235d2a292c44c0276 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
> cat A.pm | |
class A { ... } | |
role R { | |
has A $!private; | |
method r { | |
self!s; | |
} | |
method !s { | |
$!private!s if $!private; | |
say $.b; | |
} | |
method set_private(A $a) { | |
self!private = $a; | |
} | |
} | |
class A does R { | |
has Str $.b = "secret"; | |
}; | |
> cat B.pm | |
use v6; | |
use A; | |
class B does R { | |
method b { self.r } | |
method setup { $!private = A.new; return self } | |
} | |
> perl6 -I. -e 'use A; use B; my $b = B.new; $b.set_private(A.new); $b.r' | |
No such private method '!!private' for invocant of type 'B' | |
in method set_private at /home/martin |
Author
ufobat
commented
Jul 2, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment