在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
一般来说,弱类型。
C:
printf("%c\n", 'a' + 3);
PHP:
echo 5 + "3";
还有太多其他语言。
其他回答
在Java中
String("aaa")==String("aaa") //false
//you need to use
String("aaa").equals(String("aaa")) // true
C++:
void f(int bitand i){ //WTF
i++;
}
int main(){
int i = 0;
f(i);
cout << i << endl; //1
return 0;
}
在JavaScript中,看到!!第一次使用A(作为一种转换为布尔值的方式)。
我有点纠结:
1;
在perl中,模块需要返回true。
我一直在想为什么最简单的程序是:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
然而它可以是:
print "Hello World!"
也许这是为了吓唬计算机科学专业的学生……