How do I use the fetch method for nested hash?

后端 未结 7 1453
后悔当初
后悔当初 2021-02-19 14:45

I have the following hash:

hash = {\'name\' => { \'Mike\' => { \'age\' => 10, \'gender\' => \'m\' } } }

I can access the age by:

7条回答
  •  心在旅途
    2021-02-19 15:22

    if you can

    use:

    hash[["ayy","bee"]]
    

    instead of:

    hash["ayy"]["bee"]
    

    it'll save a lot of annoyances

提交回复
热议问题