|
|
|
|
|
by cmroanirgo
2751 days ago
|
|
Agreed. That said, I've come across code where the variable is always on the right. This often seems to be a throwback for some devs to alleviate the problem of mixing up equality and assignment. That is, it seems that some people have been taught to use this expression (& stick to it religiously): if (5 == x) ... simply so that if they make a mistake and type if (5 = x) ... the (C/C++) compiler will reject it. So, these people always write the slightly more awkward case (imho) of: if (5 < x && 10 > x) ... but to me it doesn't read as cleanly, because we don't say it that way. Of course, there's the problem of understanding the meaning of 'between' which can be inclusive of the end points, or exclusive...and you really can't tell from the english. In every case, it needs to be clarified. (eg 'pick a number between 1 and 10'): if (x>=1 && x<=10)... |
|