Have looked at this question: To ternary or not to ternary?, however it didn't really provide me with an answer to this situation.
I've been using ternary in if statements, as it, according to me, provides more logic and requires less operations to actually work. An example of such statement is: if (a == 'foo' ? b != 'poo' : true)
, which of course can be replaced by if ((a == 'foo' && b != 'poo') || a != 'foo')
. If comparing the number of operations - between 1 and 2 for ternary and 2 and 3 for non (of course this is a trivial example - I can as well create an example where the difference is greater than 1), it's also a cleaner than the non-ternary (at least for me); however my co-workers have been asking why have I adopted such convention.
Are there any caveats of using ternaries within conditionals (apart for readability - I'm still considering a ? b ? c ? d : e : f : g
inhumane thing to parse)?