develooper Front page | perl.perl6.users | Postings from January 2022

How to use WHY on a object's method?

Thread Next
From:
David Emanuel da Costa Santiago
Date:
January 17, 2022 17:33
Subject:
How to use WHY on a object's method?
Message ID:
6f634079-1097-df2b-66bf-9edaab6073ac@gmail.com

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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About