From: Brian Candler Date: 2010-06-18T00:07:11+09:00 Subject: Re: shorthand Rick Denatale wrote: > The difference between > > x ||= 5 > > and > > x = x | | 5 > > is that if x has a truthy value, then NO assignment will be done in > the first case (including assignment through a 'setter' method) in the > first case, but it will in the second. I never said that foo.x ||= 5 behaves like this. This *is* a method call (:x=) not a local variable assignment. class Foo def initialize(x=nil) self.x = x end def x @x end def x=(x) puts "set to #{x}" @x = x end end f = Foo.new f.x ||= 3 f.x ||= 5 -- Posted via http://www.ruby-forum.com/.