Created
August 19, 2020 20:42
-
-
Save lizmat/4bb3e1d997f9e6a84256d985815a431d to your computer and use it in GitHub Desktop.
PROXY role test
This file contains hidden or 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
role ProxyTweak is Proxy { | |
method new(:&FETCH!, :&STORE!, *%_) is raw { | |
my $self := self.Proxy::new(:&FETCH,:&STORE); | |
$self.VAR.TWEAK(|%_); | |
$self | |
} | |
} | |
class A does ProxyTweak { | |
has $.position; | |
method TWEAK(:$!position = 42 --> Nil) { } | |
} | |
my $a := A.new( | |
FETCH => -> $ { 666 }, | |
STORE => -> $, $ { say "store" }, | |
position => 17, | |
); | |
say $a; | |
say $a.VAR.^name; | |
say $a.VAR.position; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment