TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Does anyone else not use greater than?

2 点作者 windows2020超过 2 年前
Does anyone else not use > and >= and stick with only < and <=? If so, what was the inspiration?

8 条评论

jjgreen超过 2 年前
I do (er, don&#x27;t) do that, mostly, just so the arguments are size-increasing<p><pre><code> if ((0 &lt;= x) &amp;&amp; (x &lt; 10)) { ...</code></pre>
dave4420超过 2 年前
I do that.<p>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.<p>Unfortunately my code reviewers tend not to like it when I write constant &lt; variable.
grandmaa超过 2 年前
I like to be fair to all the comparators and use the greater than, equal to or less than operator:<p><pre><code> &lt;=&gt; </code></pre> Admittedly it&#x27;s only good for checking that a value isn&#x27;t NaN.
mac3n超过 2 年前
I always use &lt;, &lt;=, for consistency and to make the ordering clear<p>in mathematical notation, 0 &lt;= i &lt; n is sometimes used for summations where i ranges from 0 through n-1
joshxyz超过 2 年前
the 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..<p>which is why you always want the larger ones on the right.
ffhhj超过 2 年前
It should rhyme:<p><pre><code> if (x &gt; y) x = y;</code></pre>
jstx1超过 2 年前
Probably the other way around, I’m more likely to use &gt; and &gt;=.
muzani超过 2 年前
I use `x &gt; 0` for comparisons with 0 and negative