I'm trying to understand how yield works in Ruby?
def ablock
i = 1
j = 2
yield(i, j, 3, 4)
end
ablock do |x| puts x
end
This gives me an output of - 1 2 3 4
But,
def ablock
i = 1
j = 2
yield(i, j, 3, 4)
end
ablock do |x,y| puts x, y
end
Gives me only 1 2 as the output. Why don't 3 & 4 print?