于 2010年06月18日 13:50, Richard Hainsworth 写道:
'flip' has more uses than just for strings. For example, it flips the key/value in a pair. Hence,

my %h = <a b c d> Z 1,2,3,4; # a neat way of specifying a hash in terms of two lists say (map { .flip }, %h).perl; # the .perl gives you more information about the structure of the result. # ("3\tc", "1\ta", "2\tb", "4\td")
I don't think that's the story. In you example, "flip" coerce the key/value pair into a string, hence flip it. The effect you actually want to get is supposed to be done by the following code:

my %h = <a b c d> Z 1, 2, 3, 4;
say %h.invert.perl;

Reply via email to