View Single Post
  #10   Spotlight this post!  
Unread 05-04-2010, 14:48
Al3+'s Avatar
Al3+ Al3+ is offline
ARTist
AKA: Anthony
FRC #0840 (Aragon Robotics Team)
Team Role: Programmer
 
Join Date: Oct 2009
Rookie Year: 2008
Location: San Mateo, CA
Posts: 58
Al3+ is a jewel in the roughAl3+ is a jewel in the roughAl3+ is a jewel in the rough
Re: Ternary operators

Quote:
Originally Posted by FRC4ME View Post
Code:
return isReversed
    ? !wpiSolenoid.get()
    : wpiSolenoid.get();
Technically this could be also written:
Code:
return isReversed ^ wpiSolenoid.get(); // if reversed, then flip solenoid value
though the ?: version is arguably more readable.
__________________
cout << "Hello, robotics. Goodbye, world." << endl;

"The two-axis accelerometer provided in the kit of parts (shown in the picture below) is a two-axis accelerometer." - WPILib User's Guide