Argument Comparison Order

I am an experienced programmer and therefore I feel a little confused asking this question, but decided to do it anyway.

I am reading this book and also see various examples on the net where the order of the arguments in the comparison operation is canceled, and I wonder if there is a reason for this, or simply because it looks β€œcool” and does the same.

Example:

I would encode:

if(bool_variable == YES)

while I saw in this book and in various examples

if(YES == bool_variable)

Explanation?

Thank you, ton!

+3
source share
2 answers

, yoda, , = ==. :

if (var = YES)

, , , , . :

if (YES = var)

. , , .

+6

Carl - , , .

, , , , , , , , , , , .

, .

0

Source: https://habr.com/ru/post/1763671/


All Articles