Returning from closures
In a closure a hard return
should return from the caller, while an implicit return should return from the closure. For example:
def foo:
[10, 20, 30].each -> (number):
return number
foo
Here foo
would return 10
because of the hard return
. Had the return
been left out the method foo
would return the result of Array#each
.