DEV Community

Discussion on: When is code "too clever" / how do you think about readability/cognitive load?

Collapse
 
alainvanhout profile image
Alain Van Hout

The principle of least surprise is typically a good guideline. As such, the explicit if statement will usually be the obvious choice. Unless of course the situation is atypical and both are equally unsurprising e.g. when you are the only one who will ever work on the code (say, a hobby project) or there are clear conventions in your team, and the && conditional made it on that list.