Array to Hash

simply amazing solution fr the humble Nobu.
Now, I can do:

module Enumerable
def to_h
inject({}) {|h, (k, v)| h[k] = v; h}
end
end
==>nil
h = {“x”=>1,“y”=>2}
==>{“x”=>1, “y”=>2}
a = h.to_a
==>[[“x”, 1], [“y”, 2]]
h2 = a.to_h
==>{“x”=>1, “y”=>2}

sorry, the last lines were cut-off by my window

h = h.to_a.to_h
==>{“x”=>1, “y”=>2}
a = a.to_h.to_a
==>[[“x”, 1], [“y”, 2]]

···

Now that is Ruby.


Nobu Nakada

thank you and
kind regards -botp