Thorough use of 'if' statements or 'try/catch' blocks?

前端 未结 9 1895
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 03:14

Give me some of your thoughts on which is a better coding practice/makes more efficient code/looks prettier/whatever: Increasing and improving your ability to use if statem

9条回答
  •  北海茫月
    2021-01-12 04:09

    if blocks are slightly faster; if you aren't going to need a dozen of them, they're a better idea than try/catches. Exceptions should be exceptional, not every time the code runs. I use Exceptions for rare events like server disconnections (even though they happen a few times every day), and if blocks for any of my controllable variables.

提交回复
热议问题