4 ms·
Ask HN: Does anyone else not use greater than?
Does anyone else not use > and >= and stick with only < and <=? If so, what was the inspiration?
- jstx1 4y agoProbably the other way around, I’m more likely to use > and >=.
- jjgreen 4y agoI do (er, don't) do that, mostly, just so the arguments are size-increasing if ((0 <= x) && (x < 10)) { ...
- mac3n 4y agoI always use <, <=, for consistency and to make the ordering clear in mathematical notation, 0 <= i < n is sometimes used for summations where i ranges from 0 through n-1
- grandmaa 4y agoI like to be fair to all the comparators and use the greater than, equal to or less than operator: <=> Admittedly it's only good for checking that a value isn't NaN.
- dave4420 4y agoI do that. I visualise the variables as being on the number line. If they’re the way round that they appear in the code, then the condition is true. Unfortunately my code reviewers tend not to like it when I write constant < variable.
- ffhhj 4y agoIt should rhyme: if (x > y) x = y;
- muzani 4y agoI use `x > 0` for comparisons with 0 and negative
- joshxyz 4y agothe inspiration is the number line, small numbers at the left, larger numbers at the right, because we write left to right, and the sequence is 1 2 3 4.. which is why you always want the larger ones on the right.