From: Logan Capaldo Date: 2006-02-23T12:07:47+09:00 Subject: Re: setting nil to zero On Feb 22, 2006, at 9:38 PM, Pe�a, Botp wrote: > Hi, > > is there a setting to set nil to zero? something like $NIL=0, then > set it back again to $NIL=nil... > > reason is i have quite a number of codes like ff > > s.each do |w| > f[w] = 0 unless f[w] #i want to kill this lne since it does not > jive with my pseudocode > f[w] += 1 > end > > thanks and kind regards -botp > s.each do |w| f[w] = f[w].to_i + 1 # Or if f[w] can be a float, f[w].to_f end