Over a million developers have joined DZone.

Array To Hash In Ruby

DZone's Guide to

Array To Hash In Ruby

· ·
Free Resource
Inspired by something Ryan Carver was trying to do:

a = [1, 2, 3]
Hash[*a.collect { |v|
    [v, v*2]

It's not as foolproof as his solution, however!

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}