Skip to content

Instantly share code, notes, and snippets.

@Alex-Tideman
Created September 14, 2015 21:25
Show Gist options
  • Save Alex-Tideman/1d9ff49b08fc330304d7 to your computer and use it in GitHub Desktop.
Save Alex-Tideman/1d9ff49b08fc330304d7 to your computer and use it in GitHub Desktop.
data = { an_outer: "hash",
with_another: {
inner: "hash",
and_another: {
inside: "that"
}
}
}
array = [:with_another, :and_another, :inside]
def get_in(data,array)
if array.size > 1
key = array.shift
get_in(data[key], array)
else
p data.values.first
end
end
get_in(data,array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment