if(true)的目的 [英] purpose of if (true)
本文介绍了if(true)的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我见过这样的代码:
if (true) {
... // do something
}
你为什么要做这样的事情?这个结构有什么特别之处吗?
Why would you want to do something like this? Is there any thing special about this structure?
谢谢
推荐答案
几乎任何现代编译器都会优化这个远。我的猜测是有人在开发过程中把它放在那里让他们轻松删除一段代码(通过将 true
更改为 false
),要么忘记了,要么在完成后就不用去除它。
Pretty much any modern compiler would just optimize this away. My guess is that someone put it there during development to let them easily remove a block of code (by changing true
to false
), and either forgot or didn't bother to remove it when they were done.
这篇关于if(true)的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文