What's the most most ruby-like way of converting from an Array
like [:one, 1, :two, 2]
to a Hash
like {:one => 1, :two => 2}
?
Here's how I would do it:
Hash[*array]
Hash[*[:one, 1, :two, 2]]
#=> {:one => 1, :two => 2}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With