From: Rein Henrichs Date: 2010-06-08T05:30:06+09:00 Subject: Re: Question about abbreviated indexing assignments On 2010-06-07 12:18:39 -0700, Rick DeNatale said: > 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 Good explanation in that post, Rick. Thanks! -- Rein Henrichs http://puppetlabs.com http://reinh.com