Skip to content

Instantly share code, notes, and snippets.

@qrush
Created August 1, 2008 17:48
Show Gist options
  • Save qrush/3649 to your computer and use it in GitHub Desktop.
Save qrush/3649 to your computer and use it in GitHub Desktop.
irb(main):003:0> a = [['a', 1], ['b', 2], ['c', 3]]
=> [["a", 1], ["b", 2], ["c", 3]]
irb(main):004:0> a.flatten
=> ["a", 1, "b", 2, "c", 3]
irb(main):005:0> b = {}
=> {}
irb(main):006:0> a.each{|p| b[p[0]] = p[1] }
=> [["a", 1], ["b", 2], ["c", 3]]
irb(main):007:0> b
=> {"a"=>1, "b"=>2, "c"=>3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment