Re:Avoid Else, Return Early (2013)
by vidarh on Monday March 26, 2018 @09:11AM
(#16678555)
Actually, in Ruby we have "ensure"
The "ensure" blocks gets executed whether or not you return early, throw exception or return at the end of the block.
[ Parent
| on HN ]
Re:Avoid Else, Return Early (2013)
by SideburnsOfDoom on Monday March 26, 2018 @09:12AM
(#16678572)
There are several constructs for it, see also "try ... finally" on C# and Java, and "using" statements in C#.
All make the "goto manual cleanup at end" less necessary, and make early return easier to use.