Method: Hash.zip
- Defined in:
- lib/core/facets/hash/zip.rb
.zip(keys, values) ⇒ Object
Creates a new hash from two separate arrays, a keys array and a values array.
Hash.zip(["a","b","c"], [1,2,3])
# => { "a"=>1, "b"=>2, "c"=>3 }
CREDIT: Trans, Ara T. Howard
11 12 13 14 15 |
# File 'lib/core/facets/hash/zip.rb', line 11 def self.zip(keys,values) # or some better name h = {} keys.size.times{ |i| h[ keys[i] ] = values[i] } h end |