Skip to content

Instantly share code, notes, and snippets.

@ronaldxs
Created August 3, 2015 20:55
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 ronaldxs/e0a325c9e3bc716cf7f7 to your computer and use it in GitHub Desktop.
Save ronaldxs/e0a325c9e3bc716cf7f7 to your computer and use it in GitHub Desktop.
attribute mutator
class A {
has $.a;
method a is rw {
Proxy.new(
FETCH => -> $self { $!a },
STORE => -> $self, Int $v { $!a = $v * 2 }
);
}
}
my $o = A.new;
$o.a = 123;
say $o.a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment