在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
Tcl中的连接是将两个字符串添加为一个字符串:
set s1 "prime"
set s2 "number"
set s3 $s1$s2
puts s3
输出为
primenumber
其他回答
Perl的$[(已弃用),这在之前关于通用Perl变量的另一篇文章中提到过,但它值得特别提到,并有更好的解释。对$[的更改仅限于当前范围。更多的信息以及如何使用它的含义;)可以在$[中找到,请访问http://www.perlmonks.org/index.pl/?node_id=480333
在Perl中,你可以做到:
my $test = "Hello World";
substr($test, 0, 5) = "Goodbye";
print $test;
这在其他语言中可行吗?
JavaScript八进制转换“特性”是一个很好的了解:
parseInt('06') // 6
parseInt('07') // 7
parseInt('08') // 0
parseInt('09') // 0
parseInt('10') // 10
详情请点击这里。
好吧,既然问题是断断续续的,我就加入到“有趣”中来
Go(又名Issue9)使用大写的可见性:
如果你用大写字母命名某个东西,它就会被公众访问。 如果你使用小写,它将被包保护:
包装外可见:
func Print(v ...) {
}
包外不可见
func print( v ... ) {
}
你可以在这个原始答案中找到更多。
VBScript的With block:
With xml.appendChild(xml.createElement("category"))
.setAttribute("id",id)
.setAttribute("keywords",keywords)
With .appendChild(xml.createElement("item"))
.setAttribute("count",count)
.setAttribute("tip",tip)
.appendChild(xml.createTextNode(text))
End With
End With