作者:莫梓智 | 来源:互联网 | 2023-08-01 11:22
篇首语:本文由编程笔记#小编为大家整理,主要介绍了ruby中愚蠢的哈希实验相关的知识,希望对你有一定的参考价值。
foo = {"a" => {"aa" => "b"}, "b" => {"ab" => "c"}, "c" => {"ac" => "d"}}
#=> {"a"=>{"aa"=>"b"}, "b"=>{"ab"=>"c"}, "c"=>{"ac"=>"d"}}
foo.keys
#=> ["a", "b", "c"]
foo.values(&:keys)
foo.values(&:keys).each(&:values)
foo.values(&:keys).each(&:values).each(&:keys)
foo.values(&:values).each(&:keys)
foo.values(&:values).each(&:values)
#=> [{"aa"=>"b"}, {"ab"=>"c"}, {"ac"=>"d"}]
foo.values(&:keys).collect(&:values)
foo.values(&:values).collect(&:values)
foo.values(&:values).each(&:keys).collect(&:values)
foo.values(&:keys).each(&:keys).collect(&:values)
foo.values(&:keys).each(&:values).collect(&:values)
#=> [["b"], ["c"], ["d"]]
foo.values(&:keys).collect(&:keys)
foo.values(&:values).collect(&:keys)
foo.values(&:values).map(&:keys)
foo.values(&:keys).each(&:values).collect(&:keys)
#=> [["aa"], ["ab"], ["ac"]]