Leonardo Correa
Jun 16, 2022

--

This is not called "implicit else". I've heard of "early return".

The author shows simple code with one statement for the "else" path. In real world applications with complex logic, the code reads a lot better with early returns. You can easily see the reasons for the function to bail out.

I disagree with this advice. I agree that short code is not always the best.

--

--

Leonardo Correa
Leonardo Correa

Written by Leonardo Correa

#Australian/Brazilian, #PrincipalDev, #JiuJitsu, #SoccerPlayer, #WorldTraveller, #dad, #bjjnerd, #TheJuniorSoftwareDeveloperDream. https://febq.short.gy/CI2LFa

No responses yet