From: Dave Thomas Date: 2001-05-01T04:15:46+09:00 Subject: [ruby-talk:14451] Re: How to do it the Ruby-way 1 Steve Tuckner writes: > How does that x ||= 1 work (for us newbies)? x ||= expr is shorthand for x = x || expr So x is assigned the value in 'x', unless 'x' is false or nil, in which case 'expr' is assigned. If x is neither nil nor false, then 'expr' is not evaluated 'expr'. In a hash, h[key] is nil if the key is missing from the hash, so h[key] ||= expr assigns expr to h[key] only is h[key] is not set. Of course, the new hash defaulting mechanism coming along soon will make this kind of hack unnecessary. Regards Dave