Should switch statements always contain a default clause?

Switch cases should almost always have a default case. Reasons to use a default 1.To ‘catch’ an unexpected value switch(type) { case 1: //something case 2: //something else default: // unknown type! based on the language, // there should probably be some error-handling // here, maybe an exception } 2. To handle ‘default’ actions, where … Read more