+ 1
Ruby - Who can explain me why is output 21?
def one ->(){return 1}.call return 2 end def two Proc.new {return 1}.call return 2 end print one,two
1 Answer
+ 6
When a lambda encounters a return statement it returns execution to the enclosing method.
However, when a Proc encounters a return statement it jumps out of itself, as well as the enclosing method.
https://www.sololearn.com/learn/Ruby/2780/