"Too few positionals passed" 在带有类型捕获的无参数方法中

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

在此脚本中:

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

然后 returns:

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

知道那里等待着什么样的争论吗?

任何参数真的,因为你定义的方法 NOT 没有参数:

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

定义了一个单一的、无名的位置参数。在没有任何类型说明的情况下,它将接受 Any。所以你的问题的答案:

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

已经包含答案:Any 值 :-)