在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
Perl。
输出“Foo\n”除非$ Foo;
其他回答
在PowerShell中,你可以重命名变量:
> $a = "some value"
> $b = "a"
> $c = "d"
> Rename-Item variable:$b $c
> $d
some value
间接间接!PHP!
字面也有用:
> Rename-Item variable:d e
> $e
some value
NSIS (Nullsoft Scriptable安装系统)有StrCmp指令:
StrCmp str1 str2 jump_if_equal [jump_if_not_equal] 比较str1和str2(不区分大小写)。如果str1和str2相等,则Gotos jump_if_equal,否则Gotos jump_if_not_equal。 StrCmp $0“一个字符串”0 +3 DetailPrint '$$0 == "a string"' 转到+ 2 DetailPrint '$$0 != "a string"'
锦上添花:jump_if_equal和jump_if_not_equal也可以是负数。但我猜你们已经从正数前面的+符号中算出来了。我不记得这是强制性的,还是只是一个可怕的惯例。
这基本上结合了最差的BASIC和最差的Assembler。
c++最恼人的解析:
struct S
{
S() {} //default constructor
};
int main() {
S s(); // this is not a default construction, it declares a function named s that takes no arguments and returns S.
}
在Java中,
String s = null;
System.out.println(s + "hello");
输出“nullhello”。
英语中的虚拟语气。
等等,你是说编程语言吗?然后在C中使用(宏)绕过宏()的预处理器#定义。例如,如果有人使用#define free(…),(free)(…)将与free(…)不同。