Oh yeah, this would probably work: hash = Hash.new(0) 
but interested in the question below anyways.

thanks,
-joe

> 
> hash = {} 
> hash["key"] += 1 
>  
> generates: undefined method `+' for nil (NameError) 
> as it should.
> 
> However, if I wanted to globally override the NameError
> exception handling to do something like:
> 
> if the object is a hash element and nil, and method is +=,
> make it a number, set it to 0 and redo the operation, otherwise
> do the normal NameError procedure.
> 
> How could it be done?
> 
> I'm sure the above could be done by overriding Hash []= but
> then you may have a lot of overhead that you could avoid
> by implementing it in an exception.
> 
> thanks,
> -joe
>