在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?

请每个回答只回答一个特征。


当前回答

JavaScript:

( {} == {} ) == false

其他回答

我一直想知道这个函数在Java Core库的Math类中的用途:

static double expm1(double x);  // Returns e^x - 1.

A very tiny thing that annoyed me in COBOL was that there was no dedicated modulo operation. Instead you could do a division specifying that you only wanted whole number results and store the rest in a different variable. Since COBOL is very sensitive when it comes to variables that means that you ended up with a variable you didn't really need, i.e. the actual result of the division. This is the story of how I once named a variable "USELESS" - that was the most appropriate name I could think of.

在SQL Server中,如果你在生产代码中使用select *,你可能会遇到一个令人讨厌的意外。无论如何,使用select *并不被认为是一个好的实践,但了解一些有趣的行为是很好的。

参见问题“select * from table”vs“select colA,colB etc from table”在SqlServer2005中有趣的行为了解更多细节

再给JavaScript投一票:

parseInt('08') == 0

因为任何前导为0的数都被解释为八进制(奇怪),无效的八进制数被计算为0(坏)。我是在8月份发现这一点的,当时我几个月没碰过的代码自己崩溃了。事实证明,它本可以在10月份自行修复。

八进制支持显然已被弃用,所以未来几代的javascript将不会有这个仪式。

在ruby/python/c中,你可以像这样连接字符串:

a = "foo" "bar"
print a # => "foobar"