在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在C语言中,数组可以像这样被索引:
a[10]
这很常见。
然而,鲜为人知的形式(真正有效!)是:
10[a]
这与上面的意思相同。
其他回答
Perl的CORE::开放和标准库具有面向对象的元素,用一个过程性接口掩盖: Open (my $fh, '>', 'foobar'); Open是一个构造函数,对my()返回的引用进行操作,并接受参数'>'和'foobar'。此外,这是一个受祝福的typeglob对象(意味着它不能在对象内部保存状态)。
关于我的perlmonks post IO::File vs CORE::的更多信息,请在这里打开:http://www.perlmonks.org/?node_id=763565
FORTRAN并不是一个真正的WTF时刻,而更像是一个“为什么我需要输入所有这些垃圾时刻”
IF(12 .gt. 11) THEN
// Do some magic
ENDIF
“.gt.”在我玩这门语言的时候把我弄糊涂了,直到我意识到它是“>”符号。哦,我多喜欢不学生物,不用天天接触这些垃圾
PHP对字符串中数值的处理。详见之前对另一个问题的回答,但简而言之:
"01a4" != "001a4"
如果你有两个包含不同数量字符的字符串,它们不能被认为是相等的。前导零很重要,因为它们是字符串而不是数字。
"01e4" == "001e4"
PHP doesn’t like strings. It’s looking for any excuse it can find to treat your values as numbers. Change the hexadecimal characters in those strings slightly and suddenly PHP decides that these aren’t strings any more, they are numbers in scientific notation (PHP doesn’t care that you used quotes) and they are equivalent because leading zeros are ignored for numbers. To reinforce this point you will find that PHP also evaluates "01e4" == "10000" as true because these are numbers with equivalent values. This is documented behaviour, it’s just not very sensible.
PHP
$ php -r '::'
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
WTF ? http://en.wikipedia.org/wiki/Scope_resolution_operator
为什么不说意外的T_SCOPE_RESOLUTION_OPERATOR ?
在c#中,你可以在接口上使用new操作符。