D
David Garamond
While reading the archives, I found out about this cool "idiom":
hash = Hash[*ary]
which will turn [1,2,3,4] into {1=>2, 3=>4}. Is there anything similar
to do the opposite (i.e., turn {1=>2, 3=>4} into [1,2,3,4] or
[3,4,1,2])? I can only come up with this:
ary = Hash.to_a.flatten
hash = Hash[*ary]
which will turn [1,2,3,4] into {1=>2, 3=>4}. Is there anything similar
to do the opposite (i.e., turn {1=>2, 3=>4} into [1,2,3,4] or
[3,4,1,2])? I can only come up with this:
ary = Hash.to_a.flatten