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

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


当前回答

不知道它是否可以被认为是一种语言特性,但是,在c++中,几乎任何与模板相关的编译器错误都会每天向世界各地的许多c++程序员交付相当数量的WTF:)

其他回答

在Java中,如果x的值为NaN,则x == x返回false, x != x返回true。

Perl可以自动将26进制转换为10进制,如果你能在早上接受自己的话……

$ perl -E "say lc (@a='a'..'asdf')"
30530

Tcl在解释器中虚拟化的时间钩子非常奇怪: http://www.tcl.tk/cgi-bin/tct/tip/233.html

基本上,它允许你让解释器使用一些其他的时间数据源,例如,先在模拟器中运行硬件测试,然后替换计时器函数,对真实的东西运行相同的测试。

我发现Javascript Date Object对110年的热爱令人愉快。 试一试。

<Script language ="JavaScript">
<!--
var now = new Date()
var dia = now.getDay()
var mes = now.getMonth()
var fecha

//Day of the week
if(dia==0){
 fecha="Domingo, ";
}else if(dia==1){
 fecha="Lunes, ";
}else if(dia==2){
 fecha="Martes, ";
}else if(dia==3){
 fecha="Miércoles, ";
}else if(dia==4){
 fecha="Jueves, ";
}else if(dia==5){
 fecha="Viernes, ";
}else{
 fecha="Sábado, ";
}

fecha = fecha + now.getDate() + " de "
//Which month is it?
if(mes==0){
 fecha=fecha + "Enero"
}else if(mes==1){
 fecha=fecha + "Febrero"
}else if(mes==2){
 fecha=fecha + "Marzo"
}else if(mes==3){
 fecha=fecha + "Abril"
}else if(mes==4){
 fecha=fecha + "Mayo"
}else if(mes==5){
 fecha=fecha + "Junio"
}else if(mes==6){
 fecha=fecha + "Julio"
}else if(mes==7){
 fecha=fecha + "Agosto"
}else if(mes==8){
 fecha=fecha + "Septiembre"
}else if(mes==9){
 fecha=fecha + "Octubre"
}else if(mes==10){
 fecha=fecha + "Noviembre"
}else{
 fecha=fecha + "Diciembre"
}

//Year
fecha = fecha + " del " + now.getYear()

document.write(fecha);
//-->
</Script>

脚本是西班牙语-抱歉如果你不明白代码..这个想法是为了让你看到110年的结果。

在JavaScript中:

2 == [2]

//更陌生 2 == [[[2]]]

//和彻头彻尾的坚果 Var a = {"abc": 1}; A [[[["abc"]]]] === A ["abc"];//这也是正确的

幸运的是,stackoverflow.com网站上善良的人们向我解释了这一切:http:/stackoverflow.com/questions/1724255/why-does-2-2-in-javascript