Skip to content

Instantly share code, notes, and snippets.

@xcobar

xcobar/rb.rb Secret

Last active March 23, 2020 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcobar/eeb4f58f8c25a4d517e86c509a61222f to your computer and use it in GitHub Desktop.
Save xcobar/eeb4f58f8c25a4d517e86c509a61222f to your computer and use it in GitHub Desktop.
{
"one" => {
"M" => "A",
"N" => "B",
},
"two" => {
"O" => "C",
"P" => "D",
},
"three" => {
"Q" => "E",
"R" => "F",
}
}
# TO THIS => [["", "A", "C", "E"], ["", "B", "D", "F"]]
@havenwood
Copy link

h = {
  'one' => {
    'M' => 'A',
    'N' => 'B'
  },
  'two' => {
    'O' => 'C',
    'P' => 'D'
  },
  'three' => {
    'Q' => 'E',
    'R' => 'F'
  }
}

h.values.map(&:values).transpose
#=> [["A", "C", "E"], ["B", "D", "F"]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment