在理解 ruby 的过程中,我试图用默认参数值覆盖“+”。像这样的东西。
class C
def something(a = 5)
puts "Received: #{a}"
end
def +(b = 10)
puts "Received: #{b}"
end
end
现在
x = C.new
x.something #=> Received: 5
x.something(88) #=> Received: 88
x.+ #=> IRB shows ? whereas I was expecting an output 'Received: 10'
这是因为运算符优先级吗?