From: Rick DeNatale Date: 2010-06-08T04:18:39+09:00 Subject: Re: Question about abbreviated indexing assignments On Mon, Jun 7, 2010 at 1:05 PM, Rein Henrichs wrote: > It is commonly thought that x = y is exactly equivalent to x = x > y in all cases. What you have just demonstrated is that, > presumably for performance reasons, h[key] ||= value is in fact equivalent > to h[key] || h[key] = value, rather than h[key] = h[key] || value. This > prevents a second lookup in the case where k[key] exists and is not nil or > false. > x ||= y is NOT equivalent to x = x || y Instead a closer approximation is x || x = y http://talklikeaduck.denhaven2.com/2008/04/26/x-y-redux -- 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