Created
September 14, 2015 21:25
-
-
Save Alex-Tideman/1d9ff49b08fc330304d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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