3 ms·
Personally I don't really see what's unclear about foo(a ? b : c) In fact, I'd say your "trick" with using boolean operators on non-booleans that way is less r
by capisce 14y ago
Personally I don't really see what's unclear about foo(a ? b : c)
In fact, I'd say your "trick" with using boolean operators on non-booleans that way is less readable.
- tomlu 14y agoI don't think there is anything at all unclear about (a ? b : c). I use it all the time when programming in C and its derivatives. The (a and b or c) idiom is used in Lua, Ruby and Python (in descending order of idiomaticness). Since the person I was responding to seemed to be using syntax reminiscent of these languages, I thought I'd offer up this expression form as an alternative to resorting to statements.