4 ms·
Option 3/e: it's idiomatic in C-syntax languages to use if/then/else when you do not care about the return value. Use of ?: therefore implies that you do care a
by mooism2 14y ago
Option 3/e: it's idiomatic in C-syntax languages to use if/then/else when you do not care about the return value. Use of ?: therefore implies that you do care about the value of the expression. When I see the result of ?: being thrown away, I have to ask myself whether it is supposed to be an if/then/else, or whether a previous programmer meant to do something with the result, but forgot.
Option 4/f: if .show() always returns a truthy value, then yes, this is the same. Even if I know this is true, I must still mentally translate it into the idiomatic form. If I don't know this is true, I must waste time finding out. And if one day .show() doesn't return a truthy value --- perhaps because a different part of the codebase has been changed so that lockBtn is of a different class --- then your code will break.
- shawndumas 14y agoall true; that's why I went with b.