在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
BrainFuck语言。真的是这样!
其他回答
Perl的sub没有真正的参数列表,只有@_数组。同时,sub会自动变平传入的参数。
我不明白为什么这是一个持久的功能;这反映了几年前我不得不在TI-86 BASIC上做的事情,因为这门语言没有足够的特色。
在Java中
byte b = 0;
b++;
等于
byte b = 0;
b = b + 1;
但事实并非如此。实际上,你会得到一个编译器错误,因为加法的结果是int类型的,因此不能赋值给字节变量b。当使用复合运算符时,编译器会自动在这里插入一个类型转换。所以
b++;
就变成了
b = (byte) b + 1;
很简单,Erlang有很多。例如,标点符号的三种形式,
a_function(SomeVariable) ->
statements_end_with_commas(),
case PatternMatching of
0 -> now_we_end_with_semicolon;
true -> except_the_last_one
end.
%% Function definitions end with periods!
在Java中:
int[] numbers() {
return null;
}
可以写成:
int numbers() [] {
return null;
}
在Python中:
>>> a[0] = "hello"
NameError: name 'a' is not defined
>>> a[0:] = "hello"
NameError: name 'a' is not defined
>>> a = []
>>> a[0] = "hello"
IndexError: list assignment index out of range
>>> a[0:] = "hello"
>>> a
['h', 'e', 'l', 'l', 'o']
这些切片分配也会给出相同的结果:
a[:] = "hello"
a[42:] = "hello"
a[:33] = "hello"