How to read all keys from nested hash

below is the example hash
hash = { :a => { :b => ‘foo’ }}

in this how to access the values of key :b
not this this h[:a][:b]
i am expecting like this way h[:b]
and also i dont want full path like h[:a][:b]

hash.dig(:a, :b)
https://ruby-doc.org/core-2.3.0_preview1/Hash.html#method-i-dig

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs