Why does Lambda not return both lines "Batman will win" and "Iron Man will win"


I think I understand what the Proc.new does, it returns Batman only because it exits the calling method.

But for the lambda, since the victor is called, why doesn't if first return the Batman statement, and then continue on in the calling method, which then outputs Iron Man will win?

Is it because the Iron Man statement is not explicitly defined with a return, hence the whole calling method just returns the last statement (Iron Man will win)?

Can someone please explain this a bit clearer for me. Thanks!


We're asking puts to display the return of a method. The method can only return one object, so it will be either the batman statement or the iron man statement.

Since the lambda returns the batman statement to the method when called, the method could use this statement and return it itself, but since we have our iron man statement at the end of the method, this is what the method will return instead.

And yes, the iron man statements are implicit returns (there's a lesson on implicit returns if you want).


I had no idea that Ruby doesn't actually support returning two objects.


Well you can go around that limitation by returning an array for example. Or simply modifying the objects you receive in parameters directly.