Hash from two arrays: Difference between revisions
Content deleted Content added
m Creating a Hash from 2 Arrays moved to Creating a Hash from Two Arrays: Better title. |
→[[Ruby]]: flatten appears to be necessary here |
||
Line 176:
keys=['hal',666,[1,2,3]]
vals=['ibm','devil',123]
hash = Hash[*keys.zip(vals).flatten]
# now hash => {'hal' => 'ibm', 666 => 'devil', [1,2,3] => 123}
|