【发布时间】:2019-02-12 00:46:57
【问题描述】:
class Foo {
has &.bar;
has @.quux is required;
method clone { nextwith :quux(@!quux.clone) };
# as per <https://docs.perl6.org/type/Mu#method_clone>
};
my $f = Foo.new(quux => []);
my $f-clone = $f.clone(bar => sub { die });
# Foo.new(bar => Callable, quux => [])
但应该是
Foo.new(bar => sub { #`(Sub|94789546929784) ... }, quux => [])
将:bar(&!bar.clone) 添加到nextwith 调用没有帮助。
【问题讨论】:
-
您可以尝试将参数转发到
clone到nextsame,例如:method clone(*%twiddles) { nextwith(:quux(@.quux.clone), |%twiddles) -
确实有效,请转换为答案,以便我接受
-
@HåkonHægland 已转换。 (实际上我独立地看到了同样的事情,但我喜欢有一个很好的答案,所以我需要一段时间。在这种情况下,我找不到合适的文档引用包括
%_。我花了一段时间才放弃.) -
@raiph 优秀:)
标签: raku