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

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


当前回答

In C

a[i++] = i;

它会编译,但很少执行您认为它应该执行的操作。优化更改会产生截然不同的结果。它在不同平台上的运行方式也不同。

然而,编译器对此非常满意。

其他回答

s a=“a=”“a=”a“”,@a=“”“”2N“”“”,a=“c=”_(“”22“”?@a),@a“”,@a,a=“a”“,a(c)=”“S+”“_c,e=$T(@@a@(c))”,@a

这是COS (cache objectscript)中很好的一行代码。有趣的是,这里有5种不同的代码-间接*G模式

Perl充满了奇怪但整洁的特性。

If可以用在语句之前或之后,就像这样:

print "Hello World" if $a > 1;    
if ($a > 1) { print "Hello World"; }

foreach也是如此:

print "Hello $_!\n" foreach qw(world Dolly nurse);

在JavaScript中:

 '5' + 3 gives '53'

 '5' - 3 gives 2

我曾经写过一种编程语言,它有一个“strfry”操作符:

"hello world"?
# => "wdo rlholle"

有用的,是吗?

JavaScript日期全是WTF。

var d = new Date("1/1/2001");

var wtfyear = d.getYear(); // 101 (the year - 1900)
// to get the *actual* year, use d.getFullYear()

var wtfmonth = d.getMonth(); // 0
// months are 0-based!