在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
当今所有语言:
TypeA a = (TypeA)some_operation_returning_TypeB(1,2,3); // TypeB is not inheriting TypeA
在运行时失败,并带有"Cast to TypeA failed exception"-消息(或类似消息)。这告诉我们程序员到底有多懒。他们没有办法产生消息“未能将TypeA的变量‘a’与TypeB的值‘some_operation_returning_TypeB(1,2,3)’赋值”。他. .他们的座右铭是“犯错误的人必须受苦”。
其他回答
在c++中,你可以做:
std::string my_str;
std::string my_str_concat = my_str + "foo";
但你不能:
std::string my_str_concat = "foo" + my_str;
操作符重载通常服从WTF。
通知7。一个有效程序的例子:
Chomsky is a room. A thought is a kind of thing. Color is a kind of value. The colors are red, green and blue. A thought has a color. It is usually Green. A thought can be colorful or colorless. It is usually colorless. An idea is a thought in Chomsky with description "Colorless green ideas sleep furiously." A manner is a kind of thing. Furiously is a manner. Sleeping relates one thought to one manner. The verb to sleep (he sleeps, they sleep, he slept, it is slept, he is sleeping) implies the sleeping relation. Colorless green ideas sleep furiously.
像图灵机模拟器这样的其他愚蠢的东西可以找到。
C和c++中的三联体。
int main() {
printf("LOL??!");
}
这将打印LOL|,因为trigraph ??!转换为|。
JavaScript八进制转换“特性”是一个很好的了解:
parseInt('06') // 6
parseInt('07') // 7
parseInt('08') // 0
parseInt('09') // 0
parseInt('10') // 10
详情请点击这里。
交替:在许多语言中的事物之间交替:
boolean b = true;
for(int i = 0; i < 10; i++)
if(b = !b)
print i;
乍一看,b怎么可能不等于它自己呢? 这实际上只会打印奇数