Try putting the method definition before the block:
def mult(x,y)
x*y
end
(1…5).each do |n|
mult(n,2)
end
This should work, I’m pretty sure. It has to do with the way Ruby treats
methods/variables that are first defined/invoked in a block. Since
blocks open up a new scope (even if it’s just a nested scope
encompassing the previous), anything the parser sees that’s first
referenced in a block and isn’t defined will throw an error.