DEV Community

loading...

Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

Collapse
kant2002 profile image
Andrii Kurdiumov

To answer question which you ask Cinematic.

So, to answer your own question... why 'should' a language have an 'else' statement? What's the use case that makes it mandatory?
Enter fullscreen mode Exit fullscreen mode

You most likely need else to express computations which has 2 and only 2 options. These should be probably small computations hidden in their own function.

These situations very often arise when you express business rules for example. And written in if/else fashion these business rules can be discussed with business persons without to teaching them new abstractions.