在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在Ruby中…
i=true
while(i)
i=false
a=2
end
puts defined?(a) // returns true
其他回答
我为客户端编写了一种编程语言(用于实验驱动定制硬件),其中包含一些定制类型(Curl, Circuit,…),每种类型只有2个值。它们可以隐式地转换为布尔值,但是(在客户机的请求下)可以在运行时更改此类类型常量的确切布尔值。
例如: Curl类型有2个可能的值:CW和CCW(顺时针和逆时针)。在运行时,你可以通过一个简单的赋值语句改变布尔值:
ccw := true
所以你可以改变所有这些类型值的布尔值。
c++最恼人的解析:
struct S
{
S() {} //default constructor
};
int main() {
S s(); // this is not a default construction, it declares a function named s that takes no arguments and returns S.
}
我发现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年的结果。
在c#中,这至少应该生成一个编译器警告,但它没有:
public int Something
{
get { return Something; }
set { Something = value; }
}
当被调用时,它会导致你的应用程序崩溃,你不会得到一个好的堆栈跟踪,因为它是一个StackOverflowException。
C的多个名称空间:
typedef int i;
void foo()
{
struct i {i i;} i;
i: i.i = 3;
printf( "%i\n", i.i);
}
或与字符:
typedef char c;
void foo()
{
struct c {c c;} c;
c: c.c = 'c';
printf( "%c\n", c.c);
}