I am trying to get a general solution to the problem of accessing an element in a nested hash given by an array of key values, for example:
hash = { "a" => { "b" => 'foo' }} array = ["a", "b"] function(array) => "foo"
I guess it could be single line. This is also pretty closely related to this problem: Ruby converts the array to a nested hash
source share