Robert Klemme
2/23/2006 9:16:00 AM
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
.... and if f is not a Hash you can do
f[w] = (f[w] || 0) + 1
Kind regards
robert