Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Too few positionals passed" in arg-less method with type captures

Tags:

raku

In this script:

role Capturer {
    method capturing(::CLASS:D: $ ) {
        say "Working with ", $?CLASS, " that holds ", $.gist;
    }
}


( <1 2 3 4> but Capturer ).capturing();

A arg-less method is defined, capturing, but if I call it this way, I get:

Too few positionals passed; expected 2 arguments but got 1
  in method capturing at captured-class.p6 line 4
  in block <unit> at captured-class.p6 line 10

I can fix that giving it a dummy argument

Too few positionals passed; expected 2 arguments but got 1
  in method capturing at captured-class.p6 line 4
  in block <unit> at captured-class.p6 line 10

Which then returns:

Working with (List+{Capturer}) that holds (1 2 3 4)

Any idea of what kind of argument is waiting for there?

like image 350
jjmerelo Avatar asked Feb 23 '20 09:02

jjmerelo


1 Answers

Any argument really, because the method you defined is NOT argumentless:

method capturing(::CLASS:D: $ )
                           ^^^

that defines a single, nameless positional argument. Which, without any type specification, will accept an Any. So the answer to your question:

Any idea of what kind of argument is waiting for there?

already contains the answer: Any value :-)

like image 152
Elizabeth Mattijsen Avatar answered Oct 18 '22 01:10

Elizabeth Mattijsen