Ruby - Blocks, Procs, and Lambdas
Why does a
return inside a Proc cause the enclosing method to exit, but inside a lambda it does not?return inside a Proc cause the enclosing method to exit, but inside a lambda it does not?Proc shares the return context of the method where it is defined, so its return exits that method.lambda behaves like an independent function or method, so its return exits only the lambda block, not the enclosing method.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions