I have Hash like this, representing a data tree
hash = {
'key1' => {
'sub1' => 1,
'sub2' => 2
},
'key2' => 3
}
I want to explore the tree with an array of keys representing a path.
Some exemples :
with a simple path:
keys = ['key2']
I want to get 3
with this path:
keys = ['key1', 'sub1']
I want to get 1
with invalide path :
keys = ['key1', 'sub1', 'blabla']
keys = ['key1', 'blabla']
get nil
etc … etc … you get the idea
1 Answer