break in a case with return.. and for default

前端 未结 13 2080
予麋鹿
予麋鹿 2020-12-11 14:19

My OCD makes me add \"break\" when writing case statements, even if they will not be executed. Consider the following code example:

switch(option) {
    cas         


        
13条回答
  •  一向
    一向 (楼主)
    2020-12-11 15:12

    I don't personally put the breaks in, but it could help when someone else decides to move the return (-1) to outside of the switch and forgets to add break.

提交回复
热议问题