Larry , through S-ro commitbot: > +Since a C<KeyHash>, unlike a C<Bag>, is mutable, C<.pick> works > +directly on the C<KeyHash>, modifying it in place. You must copy > +the C<KeyHash> first if you don't want it modified in place.
This violates Least Surprise for me. An Array is also mutable, but it doesn't get modified in place. Generally, Perl 6 seems built around the premise that if you want to modify collection types or stringy things in place, you're to use C<.=> -- cf. chop, chomp, sort, reverse, invert, rotate, and all the methods on Numeric. There are still functions/methods which mutate by default: the push/pop/shift/unshift/splice family. But I kinda see .pick() as belonging in the former group. Oh, and see also the excellent clarification of semantic behaviours under 'rotate' in S32-setting-library/Containers.pod as to why non-mutating is a good default. // Carl