Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么"A".send('!='.to_sym, "B")在 Ruby 1.8.7 中会引发 NoMethodError 而"A" != "B"不会 - 正确的语法是Object.send什么样的?
"A".send('!='.to_sym, "B")
"A" != "B"
Object.send
!=不是 ruby 1.8 中的一种方法,它是硬连线的否定调用 ==
!=
由于问题的后半部分尚未得到回答:
'A'.send(:==, 'B').send(:!) # Ruby 1.9 !'A'.send(:==, 'B') # Ruby 1.8