3 ms·
You can't call return from inside a Proc inside a method; you will encounter a LocalJumpError.
by lcnPylGDnU4H9OF 1y ago
You can't call return from inside a Proc inside a method; you will encounter a LocalJumpError.
- vidarh 1y agoYou can call return from inside a proc all you want. You can't do so if you return the proc to an outside scope without getting LocalJumpError. E.g, given: def foo = proc do 42 end def bar = proc do return 42 end Then `foo.call` is fine, but `bar.call` will indeed give a LocalJumpError as you say. But a return in a proc that hasn't escaped its defining scope is fine: def baz = proc do return 42 end.call Calling `baz` here will just return 42 to the surrounding scope.