in reply to Why does an array "dissolve" into a hash?

Hello Cody Fendant,

As LanX says, it’s a list assignment. So

my %h = (foo => 100, bar => 333, san => @a);

is actually

my %h = ('foo', 100, 'bar', 333, 'san', '8', 'foo', '666');

The second assignment to key foo overwrites the first, so when the assignment is complete, $h{foo} is '666'.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Why does an array "dissolve" into a hash?
by Cody Fendant (Hermit) on Aug 20, 2015 at 03:54 UTC

    Ah, that makes sense. Thank you. Is the use of the word "dissolve" normal here?

      "Flattened into a list" is the commonly used, though it's a bit of a misnomer. The array doesn't get flattened into another data structure; an array simply returns its elements in list context.
      Never heard it used that way before.