Skip to content

Instantly share code, notes, and snippets.

@dakkar
Created March 21, 2017 09:48
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 dakkar/fa26e2b816f92d494b79fb89e891fcd0 to your computer and use it in GitHub Desktop.
Save dakkar/fa26e2b816f92d494b79fb89e891fcd0 to your computer and use it in GitHub Desktop.
#!perl6
use v6.c;
class Thing {
method blah($val=1) { 15+$val }
}
class Thunk {
has $.maker;
method FALLBACK(Any:D $invocant is rw: $name, |c) {
my $thing = $invocant.maker.();
$invocant = $thing;
$invocant."$name"(|c);
}
}
my $t = Thunk.new(:maker({ Thing.new() }));
say $t.perl;
say $t.blah(15);
say $t.perl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment