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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

The curious case of if-not

2 点作者 jugjug超过 4 年前

1 comment

baumandm超过 4 年前
The two if statements given aren&#x27;t logically equivalent; an equivalent version of the 2nd one would be:<p><pre><code> if (!(input.command === &quot;foo&quot; &amp;&amp; isValid(input))) { ... } </code></pre> Which IMHO is the least comprehensible.<p>You can flip the negation by swapping the if&#x2F;else blocks, but only if there is an else. Then you also get into questions about whether or not it matters which block is on top.
评论 #25864214 未加载