- Joined
- Apr 14, 2019
- Messages
- 218
- Reaction score
- 195
- First Language
- German
- Primarily Uses
- RMMV
I've seen something like this example so often now, that I just need to ask:
Is this a convention to add a break statement to any case statement, so that fallthroughs are really avoided?
I ask, because in this case they are completely unnecessary, as the return statement will already break the control follow of the whole function and not just the switch statement by returning to the calling function.
JavaScript:
MyPlugin.doConvertNumberToSomething = function(value)
{
switch(MyPlugin.Param.ConversionOption)
{
case "Option 1":
return MyPlugin.convertOption1(value);
break;
case "Option 2":
return MyPlugin.convertOption2(value);
break;
// And so on
}
}
Is this a convention to add a break statement to any case statement, so that fallthroughs are really avoided?
I ask, because in this case they are completely unnecessary, as the return statement will already break the control follow of the whole function and not just the switch statement by returning to the calling function.