DEV Community

Sandeep Balachandran
Sandeep Balachandran

Posted on

1

What goes to default section of your code?

Hey guys,
I just wonder what goes to default section of your switch statement or else part If – else – if ladder Statement . Is it the very last remaining option or an exception case besides the available options.

Top comments (1)

Collapse
 
emptyother profile image
emptyother

I usually prefer placing an exception there. In typescript i often add a assertUnreachable() method there that returns never. If an enum value goes unhandled, the compiler will give an error.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay