I have a question associated with curly braces in switch-case block
switch( conditon ) {
case val1: {
// something
}
break;
case val2: {
// something
}
break;
default:
break;
}
or something like this:
switch( conditon ) {
case val1: {
// something
break;
}
case val2: {
// something
break;
}
default:
break;
}
A I know both codes should work the same way but I think there is some irrationalities here. As the break should cause jumping out from curly braces block so theoretically second code should do smoothen like this: 1. break course jumping out of block 2. switch continues execution case val2 or default cause outside the braces there isn't any break statement.
Which version you recommend to use and Are they really working the same way?
case
blocks - they are maybe useful for delimiting the scope of variables, but they are not required. – Masterful