Re:Avoid Else, Return Early (2013)
by Wildgoose on Monday March 26, 2018 @05:00PM
(#16682547)
I sold my first program aged 15 and I'm 53 now. My experience is that the benefit of early return is to keep indentation to a minimum. To me, every time code indents it is a "context switch".
Having said that, early return should be for error/ignore situations - there should only be one return for a result and that should be at the very end of the function.
Having said that, early return should be for error/ignore situations - there should only be one return for a result and that should be at the very end of the function.