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?
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 :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With