- Home /
Question by
TruffelsAndOranges · Sep 26, 2015 at 11:12 AM ·
programmingprogramming-basics
Possible to use if-statement using the ?-operator with only a single statement?
I'm wondering if it's possible to do something along those lines:
boolExpression ? firstStatement : noStatement;
However, when I do this I get an error:
isBar() ? foo() : ;
Comment
Best Answer
Answer by Thomas-Mountainborn · Sep 26, 2015 at 11:23 AM
The ?: operator is called the ternary operator, because it takes three arguments. So, to answer your question, no.
But, is it so bad to have to write if(IsBar()) Foo(); ?
Nah, it's not so bad. Thank you for the answer.
Didn't find any information if there was a possiblity. :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to find Gameobject with given coordinates 1 Answer
Fullscreen mode stuck at windowed 0 Answers