如何在Perl 6中定义Ints的自定义类型的Ints参考?我试过这个,但它不起作用:
subset Array_of_Int of Array where *.all ~~ Int;
my $n = My::Class.new( option => < 22 3 4 5 > ); # Type check Failed in assignment to $!option; expected My::Class::Array_of_Int but got List in block <unit> at ...
解决方法
在My :: Class中:
has Int @.option;