Respond to an unknown method call
class Farragut {
method FALLBACK ($name, *@rest) {
say "{self.WHAT.raku}: $name.tc() the @rest[], full speed ahead!";
}
}
class Sparrow is Farragut { }
Farragut.damn: 'torpedoes';
Sparrow.hoist: <Jolly Roger mateys>;Output:
Farragut: Damn the torpedoes, full speed ahead!
Sparrow: Hoist the Jolly Roger mateys, full speed ahead!class L-Value {
our $.value = 10;
method FALLBACK($name, |c) is rw { $.value }
}
my $l = L-Value.new;
say $l.any-odd-name; # 10
$l.some-other-name = 42;
say $l.i-dont-know; # 42Last updated