As robtillaart pointed out, a switch doesn't know what to do with a value that doesn't have a corresponding case value, so it essentially ignores. it. As a general rule, I would always include a default statement block to cover such situations:
switch (dir) [
case 1:
//whatever case 1 should do...
break;
case 2:
//whatever case 2 should do...
break;
case 3:
//whatever case 3 should do...
break;
// more cases perhaps...
default:
Error(dir); // Probably should never be here, so complain about it.
break;
}
In this example, you might write an error-processing function, Error(dir), that passes in the value that doesn't match a case value for dir.