I was watching some tutorials on YouTube and noticed that some programmers leave the last statement in 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 statement, but after seeing the videos I realized that there is no need since it is the last one in the block. As far as I know, break
is (correct me if it is wrong) just to interrupt an instruction.
I would like if this practice can lead to some problem.