switch (input) {
case 1:
return "this is one";
break;
default:
break;
}
can return break the code?
Or it does what break does after return the result?
switch (input) {
case 1:
return "this is one";
break;
default:
break;
}
can return break the code?
Or it does what break does after return the result?
return terminates your function, so the code won't continue executing (and potentially falling through to the next case block). There's no point in using break in such a situation.