But in (condition && b) || c, if condition were true and b were false (or zero), it would return c. So that's not a correct implementation of a ternary operator.
Indeed, that's part of my point. You can do without ternary with some trickery, but best solution is to split it into real if else over multiple lines.
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.
But in
(condition && b) || c
, ifcondition
were true andb
were false (or zero), it would returnc
. So that's not a correct implementation of a ternary operator.Indeed, that's part of my point. You can do without ternary with some trickery, but best solution is to split it into real
if else
over multiple lines.