I'm a seasoned programmer and therefore feel a little embarrassed asking this question but decided to do so anyways.
I'm reading this book, and have also seen various examples across the net where the order of arguments in a compare operation is reversed and I wonder if there is a reason for it, or just because it looks "cool" and does the exact same thing.
Example:
I would code:
if(bool_variable == YES)
while I saw in this book and in various examples
if(YES == bool_variable)
Explanations?
Thanks a ton!
Some people like yoda conditions because they can help you find errors where you accidentally type = instead of ==. For example:
if (var = YES)
will compile but probably not work the way you want it to. Writing it the other way around:
if (YES = var)
will cause a compile-time error. I personally dislike this construct, but to each his own, I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With