Answers for "difference between Hash.new and Hash.new { |h, k| h[k] = [] }"

0

difference between Hash.new and Hash.new { |h, k| h[k] = [] }

h = Hash.new { |h, k| h[k] = [] }
h[:a]        # => {:a=>[]}
h[:b] << 123 # => {:a=>[], :b=>[123]}
Posted by: Guest on August-15-2021

Browse Popular Code Answers by Language