【发布时间】:2011-04-03 14:08:24
【问题描述】:
当我写下下面这行时:
if (collection.respond_to? :each && collection.respond_to? :to_ary)
我的 IDE (Aptana Studio 3) 出现以下错误:, unexpected tSYMBEG
但是,如果我添加括号,错误就会消失:
if ((collection.respond_to? :each) && (collection.respond_to? :to_ary))
或将&& 更改为and:
if (collection.respond_to? :each and collection.respond_to? :to_ary)
任何想法为什么会发生这种情况?还有&&和and有什么区别?
谢谢
【问题讨论】: