Robert Dober wrote:
> On 9/23/07, SpringFlowers AutumnMoon <summercoolness / gmail.com> wrote:
>>
>>    @total -= self[key]   # previous value goes
> Nope RHS can be nil

coz i created the Hash to default value to 0, by super(0)


>>    @total += new_value   # new value in
>>
>>    super
> I would put super first just in case it crashes anyway
> 
>       old_value = fetch(key,0)
>       begin
>           super
>           @total += new_value - old_value
>      rescue

why would it crash?  no key error?  i thought Ruby won't have a no key 
error.

-- 
Posted via http://www.ruby-forum.com/.