Yoda condition

<programming>

The programming practise of using

 if (constant == variable)

e.g.

 if (4 == foo)

instead of the more natural

 if (variable == constant)

It is named after the Star Wars character Yoda who says things like "Strong is Vader". It may have been invented as a way to prevent coding errors like

 if (count = 5)

(accidentally using a single "=" (assignment) instead of a double "==" (comparison)). The above is syntactically valid whereas the Yoda equivalent would give a compile-time error.

Last updated: 2012-06-25

Nearby terms:

YMODEM-Gyocto-Yoda conditionYOL Computersyotta-yottabyte

Try this search on Wikipedia, Wiktionary, Google, OneLook.



Loading