Issue #2006 has been updated by Alan Stebbens.

File good1.rb added

This is the same code, except without an array default value (using code to initialize a default for each key):

$ cat good1.rb 
#!/usr/bin/env ruby

h = Hash.new 
d = ['a', 'b', 'c']
puts h

d.each_with_index{|k,x|
  h[k] = [0,0] unless h.key? k
  h[k][0] += x
  h[k][1] -= x
}

puts "h.inspect = #{h.inspect}"
puts "h.keys    = #{h.keys.inspect}"
puts "h.values  = #{h.values.inspect}"

d.each{|k| puts "#{k} = #{h[k].inspect}"}

-----

 ruby good1.rb 

h.inspect = {"a"=>[0, 0], "b"=>[1, -1], "c"=>[2, -2]}
h.keys    = ["a", "b", "c"]
h.values  = [[0, 0], [1, -1], [2, -2]]
a = [0, 0]
b = [1, -1]
c = [2, -2]

----------------------------------------
http://redmine.ruby-lang.org/issues/show/2006

----------------------------------------
http://redmine.ruby-lang.org