Re: [PATCH v5 01/15] Add new git-related helper to contrib
- From
David Aguilar <davvid@gmail.com>
- Date
- May 19, 2013, 21:14 UTC
- Message-ID
- <CAJDDKr7+L1Qa9419aLabvnVPFCeLh0CZR9Vdazd8uk0biZxu1g@mail.gmail.com>
- In-Reply-To
- <CAMP44s3idD9pen0PyFuHeXQ=uphA8gVfFCEYhEnDRsx-gszbAw@mail.gmail.com>
On Sun, May 19, 2013 at 8:41 AM, Felipe Contreras <felipe.contreras@gmail.com> wrote:
Show 14 quoted lines
> On Sun, May 19, 2013 at 10:13 AM, Ramkumar Ramachandra > <artagnon@gmail.com> wrote: >> Felipe Contreras wrote: >>> How exactly is it not equivalent to len = len || 1? >> >> Here, I dug up an article for you on the issue: >> >> http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html >> >> Although it's fine in this case, I wouldn't recommend using ||= >> because of the potential confusion. > > I don't see the confusion, 'len ||= 1' is *exactly* the same as 'len = > 1 if not len', which is what I expected.
I spend more time in Python, C*, and Perl then in Ruby, and I was not confused by this at all.
It behaves just like $foo ||= 1 does in Perl.
In git.git:
$ git grep '||=' | wc -l
121
--
David