在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在找函数吗?为什么不是一门语言呢?
我喜欢PHP,但它总是这样构建:“哦,糟了!我忘了这个!让我们在函数"中添加另一个参数,结果如下:
Str_replace ($search, $replace, $subject…) Strstr ($subject, $search,…)
注意额外的下划线和参数的不同顺序。
这里还有一些东西
$a = array( 'a', 'b', 'c', 'd');
print_r($a); //Prints array( 0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd');
unset($a[2]); //Destroys the element 2 of the list
print_r($a); //Prints array( 0 => 'a', 1 => 'b', 3 => 'd');
其他回答
我不敢相信这里还没有这个:JSF属性访问。
在JSF UI标签中,你可以将服务器端对象的属性值引用到接口中:
<h:inputText value="#{myObject.property}></h:inputText>
问题是Java不支持属性,所以你必须编写以get和set开头的方法,以便将UI对象链接到服务器上的“属性”。
public void setProperty(String property){...}
public String getProperty(){...}
当我第一次学习JSF时,这让我感到困惑,我仍然认为它值得使用wtf。尽管在Java实现对c#风格属性的支持之前,确实没有其他方法可以做到这一点。
在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
PHP
来自在线文档: string implode (string $glue, array $pieces) -用字符串连接数组元素 注意:由于历史原因,implode()可以以任意一种顺序接受其形参。
这是可行的:implode($someArray, $glue)
希望他们能在PHP 6中消除这些历史怪癖。
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。
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
还有很多这样的东西。点击这里阅读完整列表。