在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
JavaScript真值表:
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
false == undefined // false
false == null // false
null == undefined // true
" \t\r\n" == 0 // true
资料来源:Doug Crockford
其他回答
在Python中:
>>> x = 4
>>> y = 1000000
>>> x is 4
True
>>> y is 1000000
False
>>>
如果你不相信,就试试吧!
JavaScript八进制转换“特性”是一个很好的了解:
parseInt('06') // 6
parseInt('07') // 7
parseInt('08') // 0
parseInt('09') // 0
parseInt('10') // 10
详情请点击这里。
在c#中,你可以在接口上使用new操作符。
我很惊讶居然没有人提到Visual Basic的7个循环结构。
For i As Integer = 1 to 10 ... Next
While True ... End While
Do While True ... Loop
Do Until True ... Loop
Do ... Loop While True
Do ... Loop Until True
While True ... Wend
因为粘!你面前的条件实在是太复杂了!
我在试图找出一个完全没有意义但无论如何都能工作的MACRO时遇到了这个。这对于objective-c是正确的,但对于其他类型的C(或者至少是gcc编译器)也可能是正确的。
NSString *oneString = @"This " @"is " @"just " @"one " @"normal " @" string";
=
NSString *oneString = @"This is just one normal string";
C风格的字符串也是如此
char* str = "this " "also " "works";