4 ms·
I don't get it. A test for (in)equality is commutative unless you're inducing side effects (i++) - and then side effects are going to be the big "cognitive loa
by thyrsus 10y ago
I don't get it. A test for (in)equality is commutative unless you're inducing side effects (i++) - and then side effects are going to be the big "cognitive load", regardless of which side of the comparison they occur. Am I dyslexic because (null != foo) is exactly as easy for me to read as (foo != null)?
- douche 10y agoIt reads awkwardly for a lot of people, to the point that some call these constructs Yoda Conditionals. I'm quite happy that all the languages I use regularly disallow assignment in ifs, at least.
- irishsultan 10y agoAt least in C++ you shouldn't count on the order in which a and b are calculated in a == b, because comparisons are not sequence points. So no, even including side effects testing for (in)equality is commutative.