Wednesday, June 24, 2015

How to provide a default value for all elements in a hash

a = Hash.new(0)
 => {}
> a['x']
 => 0