I can construct a hash as follows with the hash constructor:
my $h={entry=>"hello"};
However if this is used at the end of a map statement, I get a list of pairs:
[^3].map({ {entry=>$_} }).say;
##Output: (entry => 0 entry => 1 entry => 2)
I can fix this with a coercer to give me a list of hashes as I want:
[^3].map({ %(entry=>$_) }).say;
##Output: ({entry => 0} {entry => 1} {entry => 2})
I know the {}
operator is overloaded with block creation, but I don't understand the returning of pairs instead of a Hash in this example. Could someone enlighten me on this? Are there other situations I would get a list of pairs instead of a hash using the 'hash' constructor? Thanks!