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

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


当前回答

在Python中,至少对我来说,这是非常wft的!我第一次看的时候:

>>> "ja " * 5
'ja ja ja ja ja '

你可以将字符串相乘!WTF ? ?

PS:我认为这是因为x * n意味着:n乘以x,所以,5次“ja”是“ja”“ja”“ja”“ja”“ja”“ja”,因为你可以像这样连接字符串:

>>> "ja ""ja ""ja ""ja ""ja "
'ja ja ja ja ja '

两个代码有相同的结果(可能是相同的)

其他回答

INTERCAL中的一元运算符(AND, OR和XOR)。

不知道有没有人提过。

在Java中,在finally块中它可以返回一个值。它将停止异常的传播并覆盖正常的return语句。

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.

在c++中,你可以从空指针调用静态方法——看!

class Foo {
  public:
    static void bar() {
      std::cout << "WTF!?" << std::endl;
    }
};

int main(void) {
  Foo * foo = NULL;
  foo->bar(); //=> WTF!?
  return 0; // Ok!
}

这句话让我很意外……

我不知道这是否是真的,但我们偶然发现VS FORTRAN(66或77)不支持递归。递归是偶然的,我们的默认F77支持它很漂亮,但当我们把源代码IBM - Whatta混乱。