Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created August 19, 2020 20:42
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 lizmat/4bb3e1d997f9e6a84256d985815a431d to your computer and use it in GitHub Desktop.
Save lizmat/4bb3e1d997f9e6a84256d985815a431d to your computer and use it in GitHub Desktop.
PROXY role test
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