Last active
December 22, 2015 03:33
-
-
Save marlabrizel/5b84a29a94d192a19793 to your computer and use it in GitHub Desktop.
Ruby version of clojure's get in method
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
def get_in(data, array) | |
if array.size > 1 | |
key = array.shift | |
get_in(data[key], array) | |
else | |
return data.values.first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original problem: https://github.com/turingschool/challenges/blob/master/get_in.markdown