在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
雅达利基本:
你可以在不写循环的情况下用字符填充字符串:
10 DIM A$(100)
20 A$(1)=" ":A$(100)=" ":A$(2)=A$
其他回答
C# has a feature called "extension methods", which are roughly analogous to Ruby mix-ins - Essentially, you can add a method to any pre-existing class definition (for instance, you oould add "reverse()" to String if you were so inclined). That alone is fine- The "Weird" part is that you can add these extension methods, with a method body and everything, to an interface. On the one hand, this can be handy as a way to add a single method to a whole swath of classes which aren't part of the same inheritance tree. On the other, you're adding fleshed out methods to interfaces, essentially breaking the very definition of an interface.
Java的Integer类的基转换静态方法。P似乎很少有语言内置了这个功能。
这缺少了一个奇怪的特性:Python没有switch语句(尽管存在变通方法)。
在JavaScript中,undefined是一个全局变量,其默认值为原始值undefined。你可以改变undefined的值:
var a = {};
a.b === undefined; // true because property b is not set
undefined = 42;
a.b === undefined; // false
由于undefined的可变性,通过typeof检查undefined通常是一个更好的主意:
var a = {};
typeof a.b == "undefined"; // always true
foo是什么数据类型?
SELECT TOP 1
NULL AS foo
INTO
dbo.bar
FROM
sys.columns --trivial
为什么所有东西都归零?
SELECT CAST('' AS int), CAST('' AS datetime), CAST('' AS float)
...除了这
SELECT CAST('' AS decimal)