Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 414 Bytes

create-a-hash-from-an-array-of-arrays.md

File metadata and controls

18 lines (14 loc) · 414 Bytes

Create A Hash From An Array Of Arrays

The ::[] method on the Hash class allows you to succinctly create a hash from an array of arrays -- or rather an array of tuples which are key value pairs.

> Hash[ [["a",2],["b",4]] ]
{"a"=>2, "b"=>4}
> Hash[ [[1,2],[3,4]] ]
{1=>2, 3=>4}

See the Hash::[] docs for more details.

h/t Josh Davey