DEV Community

Discussion on: I've never become overly convinced that switch statements are that much cleaner than `if else if else if else if else`

Collapse
 
jessekphillips profile image
Jesse Phillips

Yeah while I reach for them often I usually only see benefits in a few cases

final switch(some enum)

This means all enum values must have a case, no default.

switch (arg) {
static foreach(...) 
Case t....

Now I can build my cases at Compile time and don't need to hand the first if or start with else.

But these are only things you find in D.