Why the strange indentation on switch statements?

后端 未结 6 1086
太阳男子
太阳男子 2021-02-04 23:11

Why is the imho missing indentation of the \"case\" - keywords in a switch statement considered good style?

No indentation of the \"case\" keyword seems to be the defaul

6条回答
  •  迷失自我
    2021-02-04 23:32

    The cases are logically labels. Many people put labels at the same indentation level as the block they are in. In my opinion, that way it's easier to read through the text.

    I compare it with a timeline you can scroll through. You have markers on the time line itself, not indented into the content. You can then quickly point out where labels/markers are, without moving your eye away from the base-line.

提交回复
热议问题