View Single Post
  #1   Spotlight this post!  
Unread 04-04-2010, 22:36
biojae's Avatar
biojae biojae is offline
Likes Omni drives :)
AKA: Justin Stocking
FTC #5011 (BOT SQUAD) && FTC#72(Garage bots)&& FRC#0399 (Eagle Robotics)
Team Role: College Student
 
Join Date: Oct 2008
Rookie Year: 2008
Location: Lancaster
Posts: 276
biojae is a jewel in the roughbiojae is a jewel in the roughbiojae is a jewel in the rough
Re: Ternary operators

Instead of using the ternary operators or the if statements in your examples, why don't you just return the value of the boolean going into the if or ternary?

Instead if this:
Code:
boolean getState() {
    if(this.thing.state) {
        return true;
    else {
        return false;
    }
}
or this:

Code:
boolean getStateTernary() {
    return this.thing.state ? true : false;
}

why not just this?

Code:
boolean getState() {
    return this.thing.state;
}
__________________
FTC Team 72 - No site
FRC Team 399 - http://www.team399.org
2010 Rockwell Collins Innovation in Control Award - (Use of the CAN bus, among other reasons) Phoenix, Arizona!