Was I the only one that used these on the robot?
For those not in the know, Ternary operators are essentially an inline if statment.
Example using if statements, like mama told you to do so:
Code:
boolean getState() {
if(this.thing.state) {
return true;
else {
return false;
}
}
Example using the ternary operators:
Code:
boolean getStateTernary() {
return this.thing.state ? true : false;
}
It does the same thing but is way easier.
The layout is:
Code:
variable = [boolean condiditon] ? [if its true] : [if its false];
This works in C, C++, Java, and I believe C#.
Did anyone else use these?