Difference between using if statement vs. ? :

 

It looks to me like these two statements are functionally equivalent to each other. Is this correct? Are there any nuances I'm missing?

if(tempZigVal < (op - tempATRMax))
            sl = op - tempATRMax;
         else
            sl = tempZigVal;
sl = tempZigVal < (op - tempATRMax) ? op - tempATRMax : tempZigVal
 
rrsch: It looks to me like these two statements are functionally equivalent to each other. Is this correct? Are there any nuances I'm missing?

Yes, it is correct but you left out the ";" at the end.

sl = tempZigVal < (op - tempATRMax) ? op - tempATRMax : tempZigVal;
 
Fernando Carreiro #:

Yes, it is correct but you left out the ";" at the end.

Of course. Thanks!

Reason: