标签: ruby hash key
如何从看起来像这样的哈希中获取1?
1
{{1=>2} => 3}
答案 0 :(得分:7)
{{1=>2} => 3}.keys #=> [{1=>2}] {{1=>2} =>3 }.keys[0] #=> {1=>2} {{1=>2}=>3}.keys[0].keys #=> [1] {{1=>2}=>3}.keys[0].keys[0] #=> 1
答案 1 :(得分:3)
{{1=>2}=>3}.keys.first.keys.first