I reckon that it all depends on what is your target.
Return statements, of course, you can easily use approach 2 or ternary operation. However, if you do any operations on a particular block, rather than return, if-else if -else construction guarantees that if an expression is evaluated to true, other blocks would not be executed, hence -> save your precious runtime. Thus, it would be only visible on a high-demanding calculation blocks.
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.
I reckon that it all depends on what is your target.
Return statements, of course, you can easily use approach 2 or ternary operation. However, if you do any operations on a particular block, rather than return,
if-else if -else construction guarantees that if an expression is evaluated to true, other blocks would not be executed
, hence -> save your precious runtime. Thus, it would be only visible on a high-demanding calculation blocks.