Last active
December 15, 2016 19:05
-
-
Save hayduke19us/2a2e21c5caf9e669f5a7359cbead5d82 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 dig(data, *keys) | |
while keys.any? | |
outer_data = data[keys.shift] | |
inner_data = outer_data | |
break unless inner_data | |
end | |
inner_data | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment