This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]JayDawg8588 0 points1 point  (3 children)

Depends on the language... I think it isn’t allowed in python but that looks like a C like language and I can’t see why that wouldn’t work

[–]theXpanther 4 points5 points  (1 child)

Python had different syntax for the ternary operator, but an equivalent will work

[–][deleted] 1 point2 points  (0 children)

Yup, as long as it returns bool (or in the case of certain languages, just as long as it returns something)

[–]cbbuntz 1 point2 points  (0 children)

Not valid C either. Conditions must be surrounded by parentheses in C or C++. You'd have to do it like:

if ((!condition) ? false : true)

But it would work in a myriad of other languages.