📜  Hash.new 和 Hash.new { |h, k| 的区别h[k] = [] } - Ruby 代码示例
📅  最后修改于: 2022-03-11 15:04:46.354000             🧑  作者: Mango
代码示例1
h = Hash.new { |h, k| h[k] = [] }
h[:a] # => {:a=>[]}
h[:b] << 123 # => {:a=>[], :b=>[123]}