在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在MOD_REWRITE
RewriteRule ^([a-zA-Z0-9_-]+)\.php$ $1/ [R,NC]
RewriteRule ^([a-zA-Z0-9_-]+)/$ $1\.php [NC,L]
将会导致:
"file.php > file > file.php > file > file.php > file > ..."
最后:
Error 500 Too Many Redirects
(一般来说,我发现编辑.htaccess文件和构造一个正常运行的正则表达式一样乏味。)
其他回答
In C
a[i++] = i;
它会编译,但很少执行您认为它应该执行的操作。优化更改会产生截然不同的结果。它在不同平台上的运行方式也不同。
然而,编译器对此非常满意。
在C中,a[b][C]与C [b[a]]完全相同。
在JavaScript中,void不是关键字,不是类型声明,也不是变量名,也不是函数,也不是对象。Void是一个前缀操作符,类似于-、——、++和!你可以给任何表达式加上前缀,这个表达式的值将是undefined。
它经常被用在bookmarklet和内联事件处理程序中,比如下面这个比较常见的例子:
<a href="javascript:void(0)">do nothing</a>
在这个例子中使用它的方式使它看起来像一个函数调用,而实际上它只是一种获得原始未定义值的过于聪明的方法。大多数人并没有真正理解JavaScript中void的真正本质,这可能会导致许多讨厌的bug和奇怪的意想不到的事情发生。
不幸的是,我认为void操作符是在JavaScript中获得未定义值的唯一真正保证的方法,因为未定义,正如在另一个回答中指出的,是一个可以重新赋值的变量名,而{}。a可以被Object.prototype.a = 'foo'打乱
更新:我想到了另一种生成undefined的方法:
(function(){}())
嗯,有点啰嗦,返回“undefined”是它的目的就更不清楚了。
我一直在想为什么最简单的程序是:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
然而它可以是:
print "Hello World!"
也许这是为了吓唬计算机科学专业的学生……
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
还有很多这样的东西。点击这里阅读完整列表。