You need the method object, and you can't get that from $a.test -- Try using the following:
when X::AdHoc { say $a.^lookup('test').WHY; # TODO: This is wrong :-( } I've tested it here ( https://replit.com/@Xliff/ThinDutifulExtensions#main.raku) and it works! :) -X On Mon, Jan 17, 2022 at 12:33 PM David Emanuel da Costa Santiago < deman...@gmail.com> wrote: > > Hello Rakuns, > > How do i access the declarator block of my object method? > > I'm trying to do this, but it's not working: > > class A { > > #|( This is just a test with 3 parameters: > * p1 - parameter 1 > * p2 - parameter 1 > * p2 - parameter 1 > ) > method test($p1, $p2, $p3) { > say "Invoked: [$p1] [$p2] [$p3]"; > } > } > > sub MAIN(*@args) { > my $a = A.new; > $a.test(|@args); > CATCH { > when X::AdHoc { > say $a.test.WHY; # TODO: This is wrong :-( > } > } > } > > > $ raku test.raku 1 2 > Too few positionals passed; expected 4 arguments but got 1 > in method test at test.raku line 8 > in block at test.raku line 18 > in any at test.raku line 16 > in method test at test.raku line 8 > in sub MAIN at test.raku line 15 > in block <unit> at test.raku line 1 > > > Is it possible to do what i want? How can i fix it? > > I tried several ways (like trying A::test.WHY; ) and all failed... > > Regards, > David Santiago >