I want to be able to get only the elements from hash by using keys that are stored in the array.
I have a hash:
my_hash = { "2222"=> {"1111"=> "1"}, "2223"=>{"1113"=> "2"}, "12342"=> {"22343"=> "3"}}
or
my_hash2 = { "2222"=>"1", "1111"=> "2", "12342"=> "3"}
And an array:
my_array = ['2223','1113']
my_array2 = ['12342']
my_array represents the chained keys in my hash. The level of my_hash can vary from 1 to ..., therefore the length of my_array will also vary. So, I need a general solution (not only for two level-hash).
My idea is to do something like this but it is wrong.
my_hash[my_array] = '2'
my_hash2[my_array2] = '3'
In fact, I want to be able to set the values.
my_hash[my_array] = '5' would set the value of my_hash["2223"]["2223"] to 5