zip-operator


Which context confuses this Perl 6 zip operator?

假装没事ソ 提交于 2019-12-13 12:26:51
问题 Consider this program where I create a hash. I want to then change two values in it: my $hash = %( wallet => 100, gave => 0, received => 0, ); for ^1 { $hash<wallet gave> Z+= <-1 1> }; dd $hash; Like this, the last line of for doesn't do anything and there is no warning. The hash is unchanged: Hash $hash = ${:gave(0), :received(0), :wallet(100)} Adding another statement changes the behavior: my $hash = %( wallet => 100, gave => 0, received => 0, ); for ^1 { $hash<wallet gave> Z+= <-1 1>; True

Which context confuses this Perl 6 zip operator?

无人久伴 提交于 2019-12-05 02:03:33
Consider this program where I create a hash. I want to then change two values in it: my $hash = %( wallet => 100, gave => 0, received => 0, ); for ^1 { $hash<wallet gave> Z+= <-1 1> }; dd $hash; Like this, the last line of for doesn't do anything and there is no warning. The hash is unchanged: Hash $hash = ${:gave(0), :received(0), :wallet(100)} Adding another statement changes the behavior: my $hash = %( wallet => 100, gave => 0, received => 0, ); for ^1 { $hash<wallet gave> Z+= <-1 1>; True }; dd $hash; Now the inplace edit does its thing, but there's a warning (although I dispute "useless"

工具导航Map