Project

General

Profile

Bug #2004 » good1.rb

good1.rb - totoro (Alan Stebbens), 08/27/2009 01:35 PM

 
#!/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}"}
(2-2/2)