在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
SQLite允许你用你想要的任何数据类型来声明列。它查找一些特定的子字符串(“INT”、“REAL”、“TEXT”等)来确定相关性。
这使得它可以在你的类型声明:
CREATE TABLE Quirks (
X FLOATING POINT, -- = INTEGER affinity because of the "INT"
Y STRING, -- = NUMERIC affinity
);
其他回答
在Ruby中,0在条件表达式中求值为true。
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.
Perl的许多内置变量:
$# — not a comment! $0, $$, and $? — just like the shell variables by the same name $ˋ, $&, and $' — weird matching variables $" and $, — weird variables for list- and output-field-separators $! — like errno as a number but strerror(errno) as a string $_ — the stealth variable, always used and never seen $#_ — index number of the last subroutine argument... maybe @_ — the (non)names of the current function... maybe $@ — the last-raised exception %:: — the symbol table $:, $^, $~, $-, and $= — something to do with output formats $. and $% — input line number, output page number $/ and $\ — input and output record separators $| — output buffering controller $[ — change your array base from 0-based to 1-based to 42-based: WHEEE! $} — nothing at all, oddly enough! $<, $>, $(, $) — real and effective UIDs and GIDs @ISA — names of current package’s direct superclasses $^T — script start-up time in epoch seconds $^O — current operating system name $^V — what version of Perl this is
还有很多这样的东西。点击这里阅读完整列表。
JCL条件返回执行。
//STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01) .
该特性允许您根据前面步骤的返回代码运行或不运行某个步骤。真是个不错的功能。
除了一些小功能,把逻辑颠倒过来。
首先,如果条件为真,则不运行步骤。
其次,4 GT,STEP01实际上意味着“如果STEP01的返回码大于4”
因此,整个过程意味着“如果来自STEP01的返回代码大于4,则不要运行此步骤”。这与“如果4大于来自STEP01的返回代码,则运行步骤”的简单解释几乎相同,但并不完全相同。
考虑到你唯一认真看待这些事情的时间是凌晨2点30分左右,电话另一端是一个疯狂的夜班接线员,这种双重模糊会导致严重的头痛。
Javascript中的变量/函数声明:
var x = 1;
function weird(){
return x;
var x = 2;
}
Weird()返回undefined…即使任务从未发生,X也被“占用”了。
类似的,但也不是那么出乎意料
function weird2(){
var x;
return x();
function x(){ return 2 };
}
返回2。