Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is relying on short-circuit evaluation good design? [closed]

Are there alternatives that would be more preferred?

like image 495
flumpb Avatar asked Dec 17 '25 10:12

flumpb


2 Answers

Short-circuit evaluation is a crucial feature of most modern programming languages and there's no reason to avoid relying on it. Without it pointer-related tests would be (unnecessarily) much more complicated and less readable.

like image 117
Ondrej Tucny Avatar answered Dec 20 '25 02:12

Ondrej Tucny


Of course it's good design, everyone knows to expect it and it beats using nested conditionals.

like image 44
Blindy Avatar answered Dec 20 '25 02:12

Blindy