Why is &&
preferable to &
and ||
preferable to |
?
I asked someone who\'s been programming for years a
Because &&
and ||
are used for flow control just like if/else
are. It isn’t always about conditionals. It is perfectly reasonable to write as a statement, not as an if
or a while
conditional, the following:
a() && b() && c() && d();
or even
w() || x() || y() || z();
It’s not just that it those are easier to type than the equivalent if/else
versions; they are also much easier to read and understand.