In Damian's excellent perl6 talk, I think he said that by default a hash
in list context will return a list of pairs. Hence this

   @array = %hash

for %hash with n keys would give an array of n elements, all pairs.
If you want the perl5 tradition of a list alternating key,value,key,value...
you'd say

   @kv_array = %hash.kv

which would give an array of 2n elements.

What I'm not clear about is what happens the other way.

If I then write

   %hash2 = @array

presumably %hash2 is a copy of %hash, with each pair in @array initialising
one key and value in %hash2

But what happens if I write

   %hash3 = @kv_array

Is perl6 going to spot that @kv_array has an even number of entries, all
are scalars (no pairs), and so do this

   for @kv_array -> key, value {
       %hash3{$key} = $value;
   }

Or is it going to treat non-pairs like this:

   for @kv_array -> key {
       %hash3{$key} = undef; # Or some other suitable default
   }

or what?

And what happens if I write

  %hash4 = ("Something", "mixing", pairs => and, "scalars");

Nicholas Clark
-- 
Even better than the real thing:        http://nms-cgi.sourceforge.net/

Reply via email to