Should I use return/continue statement instead of if-else?

前端 未结 13 1880
时光说笑
时光说笑 2020-12-01 10:46

In C, C++ and C# when using a condition inside a function or loop statement it\'s possible to use a continue or return statement as early as possible and g

相关标签:
13条回答
  • 2020-12-01 11:21

    I generally use the if-return method when jumping out of a method or loop because there is nothing to be done.

    If the body is longer because substantial work is being done, I suggest using if-else and maybe using #region to give blocks a sensible name and have them easily collapsable for people to study the control flow. That or make separate methods :)

    0 讨论(0)
提交回复
热议问题