in reply to code that fails to act as expected...
First time call: build an array of keys in even positions and their values in odd positions and then...
All calls: shift and return the first two values in stored array.
The single-operand for loop you show calls "each" only once irrespective of what is returned and so it builds an iteration list of only one key/value pair. The reason a while loop DWIMs on the other hand is that it keeps calling "each", picking up pairs until the array it "kept to itself" is exhausted.
^M Free your mind!
|
|---|