On Thu, Dec 25, 2008 at 9:39 AM, Mark J. Reed <[email protected]> wrote:
> On Thu, Dec 25, 2008 at 12:00 PM, Patrick R. Michaud <[email protected]>
> wrote:
>> On Thu, Dec 25, 2008 at 12:53:06AM -0500, Mark J. Reed wrote:
>>> I also tried this, but it caused Rakudo to throw a StopIteration and
>>> then segfault:
>>>
>>> for [...@gifts[0..$day-1]].pairs.reverse -> $n, $g
>>
>> The StopIteration occurs when there aren't enough elements in the
>> list to supply to the parameters to the body. In the example above,
>> it would occur whenever there are an odd number of pairs.
>
> OK, so that loops through the list in groups of two. So how do I Ioop
> through a list of Pairs assigning the key to one var and the value to
> another?
There's apparently no L<S06/Unpacking a Pair> section (yet), but by
inference from the various argument unpacking syntaxes, I'd predict
the syntax should be:
for [...@gifts[0..$day-1]] -> $ ($key => $value) { ... }
- Ashley Winters