在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在Ruby中,0在条件表达式中求值为true。
其他回答
在Java中,如果x的值为NaN,则x == x返回false, x != x返回true。
来自边远吗?
任何东西都会自动将任何类名和成员名复数或单数。
例如,Linq-to-Sql
在Perl中,可以通过修改一个类的@ISA数组来改变它的继承链,这让我很惊讶。
package Employee;
our @ISA = qw(Person);
# somwhere far far away in a package long ago
@Employee::ISA = qw(Shape);
# Now all Employee objects no longer inherit from 'Person' but from 'Shape'
在x++ (Microsoft Dynamics AX):
1)需要在单独的行上使用分号(;)将变量声明与语句分开(至少在4.0版本之前)
int i;
int myArray[5];
;
i = 1;
2)数组索引是基于1的,所以你不允许像in那样使用索引0(零)从数组中读取
int myArray[5];
;
print myArray[0]; // runtime error
这并不奇怪,但是你可以在赋值的左边使用0索引,比如in
int myArray[5];
;
myArray[2] = 102;
myArray[0] = 100; // this is strange
print myArray[2]; // expcting 102?
会发生什么呢?数组被初始化为它的默认值,无论赋值中使用了什么值。上面的代码输出0(零)!