Put demonstrative condition into ternary expression

It should be made clear that the part before the ternary operator is
indeed a condition, most often created as some comparison expression.
This commit is contained in:
Guntbert Reiter 2015-10-04 16:44:24 +02:00
parent 9b46fe7e57
commit f1a90a4e63

View File

@ -236,7 +236,8 @@ on a new line! ""Wow!"", the masses cried";
// Ternary operators
// A simple if/else can be written as follows
// <condition> ? <true> : <false>
string isTrue = (true) ? "True" : "False";
int toCompare = 17;
string isTrue = toCompare == 17 ? "True" : "False";
// While loop
int fooWhile = 0;