On 22-Feb-06, at 9:38 PM, Peñá, 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 If I'm doing that with a hash then I use 0 as a default value e.g. michael-stoks-powerbook-g4-17:~ mike$ irb irb(main):001:0> f = Hash.new(0) => {} irb(main):002:0> f[7] += 1 => 1 irb(main):003:0> f => {7=>1} but I assume that you are after something more subtle... Michael -- Mike Stok <mike / stok.ca> http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.