Re:The Shapes of Code
by sinuhe69 on Monday January 27, 2020 @11:38PM
(#22166502)
Functional code would be totally different, I guess.
[ Parent
| on HN ]
Probably. This is my experience with the case of the unbalanced if.
When it happens to me in Python or Ruby, I return immediately from the smaller branch and move the other branch out of the if, to the main level.
When it happens in Elixir... It doesn't happen because I don't use ifs there. I write two versions of the same function. One matches the condition for the then branch, the other the condition for the else one.