3
I was watching some tutorials on Youtube and noticed that some programmers leave the last instruction of a block switch without the word break. For example:
switch(frutas){
case "abacaxi": abacaxi++; break;
case "morango": morango++; break;
case "pera": pera++; // sem 'break' aqui...
}
I found it interesting, at first I thought it was just Programming style. I always use break even in the last instruction, but after seeing the videos I realized that there is no need since she is the last of the block. As far as I know, the break serves (correct me if I’m wrong) just to interrupt an instruction.
I would like if this practice can lead to any problem.
If you decide to enter one more
caseat the end and forget to put thebreakin the previous, can rather give problem.– bfavaretto