Reputation: 1035
I have a string that represents a sequence of keys in a nested hash in the following format:
keys = 'key1[key2]'
and a nested hash that has the corresponding keys like the following:
hash = {key1: {key2: 'value'}}
Is there any way to get the value from this hash directly as in the following?
value = hash[keys]
Or, do I have to write my own logic?
Upvotes: 0
Views: 45
Reputation: 4920
To answer your specific question, No, there is no way (to my knowledge) to get the value from hash directly by passing your input string.
You will have to write your own logic to extract the keys from string and then fetch the value.
Upvotes: 0