From: "Mikael Høilund" Date: 2008-06-13T07:26:01+09:00 Subject: Re: ||= On Jun 13, 2008, at 0:08, Mike Cargal wrote: > this really is equivalent to a = a || b, just like a += 1 is > equivalent to a = a + 1 (same for -=, etc. However, be aware that this particular operator has an optimization making it behave like a || a = b instead. Example problem: >> h = Hash.new() { "default" } # Makes a Hash with "default" as the default value instead of nil => {} >> h[:a] => "default" >> h.has_key? :a => false >> h[:a] ||= "not default" => "default" >> h[:a] => "default" >> h.has_key? :a => false >> h[:a] = h[:a] || "not default" => "default" >> h[:a] => "default" >> h.has_key? :a => true >> -- # Mikael Høilund def method_missing(m, a=0) a + m.to_s[/[a-z]+/].size * 2; end p What is the meaning of life?