From: Rick DeNatale Date: 2010-06-16T02:42:19+09:00 Subject: Re: shorthand On Tue, Jun 15, 2010 at 1:24 PM, Brian Candler wrote: > foo ||= 5 > > is shorthand for > > foo = foo || 5 NO it is NOT, although many Rubyist seem to cling to this idea. see http://talklikeaduck.denhaven2.com/2008/04/26/x-y-redux and recent discussion on this very thread. 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. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale