The Hash::[] class method can be used in addition to the splat operator to create a hash from an array.
arr = [:a, 1, :b, 2]
Hash[*arr]
# => {:a => 1, :b => 2}
whdzera liked this You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.