Forum: Ruby Re: Loop weirdness

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kroeger, Simon (ext) (Guest)
on 2006-01-31 15:06
(Received via mailing list)
> the array. However, you are using two in your block. I
> understand (from
> looking at the code), that this assigns each value in the
> item array to
> k and v respectively, but how does that work? Is there any docs about
> that anywhere?

that's the way multiple assignement works in ruby

a, b = 1, 2

a, b = [1, 2]

is equivalent (at least for this purpose).

map yields arrays of two elements in this case and I'm assigning them to
two variables.


This topic is locked and can not be replied to.