Dealing with nested if then else/nested switch statements

前端 未结 7 1558
走了就别回头了
走了就别回头了 2020-12-30 08:43

Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements?

I remember coming across some methods used by the Google folks

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 09:09

    Have you read this on flattening arrow code from Coding Horror?

    You can replace throw with return or goto if you're using a language without exceptions.

提交回复
热议问题