There is such a line of code:

item.addProperty(SoapScheme.ROUTES.Item.OUTLET_CODE, route.outlet == null ? 0 : route.outlet.code); 

Interested in what means ? and : that is, it interests you, what exactly does this expression route.outlet == null ? 0 : route.outlet.code mean route.outlet == null ? 0 : route.outlet.code route.outlet == null ? 0 : route.outlet.code ?

  • 6
    this is a turner operation (condition? execute if yes: execute if no) - Mikhail Kolomiyets
  • ternary operator that replaces the if conditional operator - fonjeekay

2 answers 2

This is a ternary conditional operation . If route.outlet == null is true, then the value is returned after the ? if false then the value after :

    Ternary operator (or, as already mentioned above, the ternary conditional operator).

    In fact, this piece of code could be rewritten like this

     if(route.outlet == null) { temp = 0; } else { temp = route.outlet.code; } item.addProperty(SoapScheme.ROUTES.Item.OUTLET_CODE, temp);