Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 30, 2013, 22:13 UTC
- Message-ID
- <7v1u9rbrb4.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAMP44s3osZJO1P6_KoPVON0cOSAD5D-OZmL=aKGkcWReortiCw@mail.gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 8 quoted lines
> On Tue, Apr 30, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote: >> What is a Yoda condition? > > --- > Using if (constant == variable) instead of if (variable == constant), > like if (4 == foo). > > Because it's like saying "if blue is the sky" or "if tall is the man".
That is an invalid analogy, as the sentences do not make sense.
A much better explanation I heard on this list is that people do not say "If 1 is smaller than the number of your wives, you have a big problem".
I actually was not asking why people find the convention to visually align comparison with number lines unusual. We discussed this style long time ago on this list. I haven't heard the "Yoda condtion" expression and was asking about the "Yoda" part.