在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
C++:
void f(int bitand i){ //WTF
i++;
}
int main(){
int i = 0;
f(i);
cout << i << endl; //1
return 0;
}
其他回答
我有点纠结:
1;
在perl中,模块需要返回true。
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!
我很惊讶居然没有人提到Visual Basic的7个循环结构。
For i As Integer = 1 to 10 ... Next
While True ... End While
Do While True ... Loop
Do Until True ... Loop
Do ... Loop While True
Do ... Loop Until True
While True ... Wend
因为粘!你面前的条件实在是太复杂了!
这并不是说它被大量使用,而是c++的“返回对静态大小数组的引用”的语法很奇怪:
struct SuperFoo {
int (&getFoo() const)[10] {
static int foo[10];
return foo;
}
}
在上述情况下,Ofc方法可以声明为静态const
在我看来,在c#中能够将超出范围的整数转换为枚举是非常奇怪的。想象一下这个枚举:
enum Colour
{
Red = 1,
Green = 2,
Blue = 3
}
现在,如果你写:
Colour eco;
eco = (Colour)17;
编译器认为这很好。还有运行时。
请看这里了解更多细节。