▲ | vidarh 17 hours ago | |
Just to clarify here: Both lambdas and procs are Proc objects. Blocks gets turned into Proc objects when you take their value. So just be clear about whether you're talking about a proc or a Proc... > In a block or Proc, it returns from the calling method No, in block or a Proc it returns from the scope where it was defined. Usually this is the same, and so it doesn't usually matter much, but if you pass a proc or a block down to another method, then a return within the block will still return from the method where it was defined. This can occasionally be useful, as you can use it to pass in a predicate to a method that can control if/when you want to return, irrespective of how deeply nested. | ||
▲ | vidarh 12 hours ago | parent [-] | |
Too late to edit now, and this is what I get for quibbling about casing: > No, in block or a Proc it returns from the scope where it was defined. Should of course read: > No, in a block or a proc it returns from the scope where it was defined. |