可以用来聚集结点吗?

问题描述 投票:4回答:1

在此程序中:

use v6;
my $j = +any "33", "42", "2.1";
gather for $j -> $e {
    say $e;
} # prints 33␤42␤2.1␤

for $j -> $e {
    say $e; # prints any(33, 42, 2.1)
}

gather前面的for如何更改结点的行为,从而允许在结点上创建循环? documentation似乎不反映该行为。那是规格吗?

perl6 perl6-junction
1个回答
1
投票

Golfed:

    do put .^name for any 1 ; # Int
       put .^name for any 1 ; # Mu

13个statement prefixes listed in the doc中的10个中的任何一个都可以代替dogather使用,但结果相同。 (supply不会产生任何输出,hyperrace是红色鲱鱼,因为它们尝试将方法应用于结点值的尝试失败了。)

任何类型的结点都会产生相同的结果。

联结的任何数量的元素都会为for循环产生相同的结果没有语句前缀,即单个MuWithfor循环之前加一个语句前缀,将主语句(put ...)重复适当的次数。

我同时搜索了rt和gh问题,但未找到相关的错误报告。

© www.soinside.com 2019 - 2024. All rights reserved.