Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Created March 30, 2015 08:24
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 jonathanstowe/4024771e8848daf33641 to your computer and use it in GitHub Desktop.
Save jonathanstowe/4024771e8848daf33641 to your computer and use it in GitHub Desktop.
Proxy
#!perl6
use v6;
class Foo {
has $!foo_str;
method foo is rw {
Proxy.new(
FETCH => {
say "fetch";
$!foo_str;
},
STORE => -> $, $foo {
say "store";
$!foo_str = $foo;
},
);
}
}
my $foo = Foo.new;
$foo.foo = "bar";
say $foo.foo;
$foo.foo = 'baz';
say $foo.foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment