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)

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