在此脚本中:
role Capturer {
method capturing(::CLASS:D: $ ) {
say "Working with ", $?CLASS, " that holds ", $.gist;
}
}
( <1 2 3 4> but Capturer ).capturing();
定义了一个无参数方法capturing
,但如果我这样调用它,我得到:
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
我可以给它一个伪参数来解决这个问题
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
然后返回:
Working with (List+{Capturer}) that holds (1 2 3 4)
你知道在等待什么样的争论吗?
任何实参,因为您定义的方法是NOT无实参:
method capturing(::CLASS:D: $ )
^^^
它定义了一个单一的、无名称的位置参数。在没有任何类型规范的情况下,它将接受Any
。所以你的问题的答案是:
你知道在等待什么样的争论吗?
已包含答案:Any
值:-(