Skip to content

Instantly share code, notes, and snippets.

@hedgeye-bnovak
Last active January 30, 2024 20:34
Show Gist options
  • Select an option

  • Save hedgeye-bnovak/6afb75c0cf55649888f77e269028c19e to your computer and use it in GitHub Desktop.

Select an option

Save hedgeye-bnovak/6afb75c0cf55649888f77e269028c19e to your computer and use it in GitHub Desktop.
Nested Hashes - Print Keys
Given the following hash
h = {a: 1, b1: {b2: {b3: nil}, c2: nil}, c1: {c2: {c3: nil}}}
Write a function that prints out all the keys, in order of their keys (not alphabetical order)
i.e. a, b1, b2, b3, c2, c1, c2, c3
@hedgeye-bnovak

hedgeye-bnovak commented Feb 17, 2022 •

Copy link
Copy Markdown
Author
h = {a: 1, b1: {j2: {b3: nil}, r2: nil}, c1: {z2: {c3: nil}}}

@hedgeye-bnovak

Copy link
Copy Markdown
Author
h = {h: 1, e: {d: {g: nil}, e: nil}, y: {e: {s: nil}}}

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