> I want to convert an array (with pairs [key,value]) to a hash. After
> googling a bit I got:
>=20
> 1) Hash[*array.flatten]
>=20
> But this is not safe as Array#flatten is recursive.
>=20
> 2) array.inject({}) { |m, e| m[e[0]] =3D e[1]; m }
>=20
> Too ugly to consider.

array.inject({}) {|h,(k,v)| h[k]=3Dv; h}

is still ugly, but perhaps you may consider it.

Also, arrays of arrays can be used directly in a hash-like manner:

array =3D [[1,2],[3,4]]
array.assoc(3)
=3D> [3,4]

which may be useful, depending on what you're doing (it won't have hash
performance, but it may do)

Dan.