> I want to convert an array (with pairs [key,value]) to a hash. After > googling a bit I got: > > 1) Hash[*array.flatten] > > But this is not safe as Array#flatten is recursive. > > 2) array.inject({}) { |m, e| m[e[0]] = e[1]; m } > > Too ugly to consider. array.inject({}) {|h,(k,v)| h[k]=v; h} is still ugly, but perhaps you may consider it. Also, arrays of arrays can be used directly in a hash-like manner: array = [[1,2],[3,4]] array.assoc(3) => [3,4] which may be useful, depending on what you're doing (it won't have hash performance, but it may do) Dan.