Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created January 9, 2015 12:47
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 peschwa/0f8830ba3c6a2eb852ba to your computer and use it in GitHub Desktop.
Save peschwa/0f8830ba3c6a2eb852ba to your computer and use it in GitHub Desktop.
## file FooAttrTest.pl
use v6;
use Foo:from<Java>;
Foo.HOW.add_method(Foo, "baz", method ($self:) {
Proxy.new:
FETCH => method () { $self."field/get_baz/I"() },
STORE => method ($new_val) { $self."field/set_baz/I"($new_val) };
});
my $foo = Foo.new;
# .say for sort $foo.^methods;
say "hi";
say $foo.baz;
say "hi";
$foo.baz = 10;
say $foo.baz;
#`[[
public class Foo {
public int baz;
public Foo() {
baz = 5;
}
}
]]
## output
$ CLASSPATH=$PWD ./perl6-j FooAttrTest.pl
hi
5
hi
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment