Is this good practise ... ie, grouping the default case with another?
switch ($cond){
case 1:
...;
break;
case 2:
...;
break;
case 3:
default:
...;
break;
}
It makes perfect sense to do it that way.
Also, @Ian is correct, but in a limited scope. If you wanted additional functionality applied to case 3
you would leave it the way it is. As long as you don't break
, it will go on to the next case
.
It kind of makes case 3
redundant though, so I'd remove it and just leave it as default
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With