在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
通知7。一个有效程序的例子:
Chomsky is a room. A thought is a kind of thing. Color is a kind of value. The colors are red, green and blue. A thought has a color. It is usually Green. A thought can be colorful or colorless. It is usually colorless. An idea is a thought in Chomsky with description "Colorless green ideas sleep furiously." A manner is a kind of thing. Furiously is a manner. Sleeping relates one thought to one manner. The verb to sleep (he sleeps, they sleep, he slept, it is slept, he is sleeping) implies the sleeping relation. Colorless green ideas sleep furiously.
像图灵机模拟器这样的其他愚蠢的东西可以找到。
其他回答
Forth可以随时改变数字的基数:
HEX 10 DECIMAL 16 - .
0 Ok
它也不需要是预定义的:
36 BASE ! 1Z DECIMAL .
71 Ok
在C语言中,数组可以像这样被索引:
a[10]
这很常见。
然而,鲜为人知的形式(真正有效!)是:
10[a]
这与上面的意思相同。
试试吧,除非,否则
try: pass
except: pass
else: pass
finally: pass
如果没有捕获异常,则执行else部分。
有道理,但一开始我真的不知道它是干什么的。
例子:
def show_square(string):
try:
n = int(string, 10)
except ValueError:
print "I can't do that, Dave."
else:
print n * n
Java的访问修饰符对我来说是最近的一个WTF(因为我必须学习一点)。
显然,包比类层次结构更亲密。我不能定义对子类可见但对包中的其他类不可见的方法和属性。为什么我要将一个类的内部共享给其他类呢?
但是我可以定义对包内的每个类可见的属性和方法,但对包外的子类不可见。
不管我怎么想,我还是看不出其中的逻辑。切换访问修饰符,使受保护的行为就像它在c++中工作一样,并保持包的私有修饰符,这是有意义的。但现在不是了。
在Java中,
Int x = 010;
这将x赋值为8。
在Java中,任何前面带0的整数都被假定为八进制。