1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00
danbarberphoto/vendor/plugins/typus/lib/extensions/array.rb

14 lines
290 B
Ruby

class Array
##
# Taken from http://snippets.dzone.com/posts/show/302
#
# >> %W{ a b c }.to_hash_with( %W{ 1 2 3 } )
# => {"a"=>"1", "b"=>"2", "c"=>"3"}
#
def to_hash_with(other)
Hash[ *(0...self.size()).inject([]) { |arr, ix| arr.push(self[ix], other[ix]) } ]
end
end