Skip to content

Instantly share code, notes, and snippets.

@studio3104
Last active December 19, 2015 08:09
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 studio3104/5923829 to your computer and use it in GitHub Desktop.
Save studio3104/5923829 to your computer and use it in GitHub Desktop.

こういうのを、

b = {
  'AAAAA' => {
    'components' => [
      50,
      80,
      100,
    ],
    "categories" => [
      'BBBBB' => {
        'values' => [
          '101xxx',
          '102xxx',
          '103xxx',
        ]
      },
    ],
  }
}

こうしたい。hashの階層が何段階であっても最後まで辿って、配列だったら垂直に展開、みたいな

AAAAA
|
|-- components
|   |
|   |-- 50
|   |-- 70
|   `-- 100
|
`-- categories
    |
    `-- BBBBB
        |
        `-- values
            |
            |-- 101xxx
            |-- 102xxx
            `-- 103xxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment