这是来自C的保留,旧的编译器不会抓住这个:
if (foo = null)
Run Code Online (Sandbox Code Playgroud)
当你的意思是这样的:
if (foo == null)
Run Code Online (Sandbox Code Playgroud)
经典的笑话例子是这个错误:
if (fireTheNukes = true)
fireTheNukes();
Run Code Online (Sandbox Code Playgroud)
这通常被认为是一种古老的模式,因为任何有价值的编译器都会在条件语句中捕获赋值.我会在你的代码中避免这种模式,因为它现在没有任何用处.
| 归档时间: |
|
| 查看次数: |
565 次 |
| 最近记录: |