2 ms·
They were invented to defend against a (mis)feature of C and some other programming languages, where you can use '=' in an expression when you meant to use '=='
by jimrandomh 14y ago
They were invented to defend against a (mis)feature of C and some other programming languages, where you can use '=' in an expression when you meant to use '==', getting an assignment instead of a comparison. If there's a constant on the left, then this would be an error. However, most compilers now generate warnings in all of the cases where Yoda conditions would've helped, but conventions tend to outlast their purpose.