The Modern Switch Statment

switch (someInt) {
case 1:
case 2: System.out.println(“Forgot a break, idiot!”);
case 3: System.out.println(“Now you’re doing the wrong thing and maybe need hours to find the missing break muahahahaha”);
break;
default: System.out.println(“This should never happen -,-“);
}

I was think about this and its stupid, because nearly every time I write a switch statement I want to break; not wanting to is more of a freak occasion that the norm.so it would seem to me that sane thing to do is change so that instead of being break; driven they would instead be continue driven. This would solve alot of problems and many a programming bug has been caused my a missing break;

such that the new switch statment would look something like

switch (someInt) {
case 1:System.out.println(“Just minding my own business”);
case 2: System.out.println(“I nicely execute only on a 2”); continue;
case 3: System.out.println(“I execute on a 2 or a 3”);
default: System.out.println(“This should never happen -,-“);
}

Leave a Reply

Your email address will not be published. Required fields are marked *