The language that you're using can play into this as well. In Ruby, I'd have no problem with:
deffoo(should_bar)barifshould_barend
In Ruby, such shortenings are idiomatic (and easy to understand). In JavaScript I'd find the equivalent (your first example) to be too potentially confusing to leave in. I'd be thinking of future-me, who might be tired, or future-other-dev, who might not know the trick with sequential execution using &&. I'd want that person to be clear that I was making a conditional statement, without having to guess at my intent.
As for the general question of what makes a line of code "too clever", I like to stick to the old adage:
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? The Elements of Programming Style, 2nd edition, chapter 2
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The language that you're using can play into this as well. In Ruby, I'd have no problem with:
In Ruby, such shortenings are idiomatic (and easy to understand). In JavaScript I'd find the equivalent (your first example) to be too potentially confusing to leave in. I'd be thinking of future-me, who might be tired, or future-other-dev, who might not know the trick with sequential execution using
&&
. I'd want that person to be clear that I was making a conditional statement, without having to guess at my intent.As for the general question of what makes a line of code "too clever", I like to stick to the old adage: