class MyClass
def fun
a = 2
b = 5
yield(a,b)
end
def self.fun2
puts self
end
end
m = 1
n = 2
mine = MyClass.new
mine.fun {|m| puts "m = #{m} n = #{n}"}
这里我故意不匹配yield的参数个数,输出为
test.rb:16: warning: multiple values for a block parameter (2 for 1)
from test.rb:5
m = 25 n = 2
这个 25 是从哪里来的?