View Single Post
Old 06-14-2002, 05:37 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
c++ ternary operator...

this category is lagging .. so i thought i'd post something cool i learned in c++

the ternary operator ( ? : )

(condition 1) ? (expression 1) : (expression 2 )

so .. if condition 1 is true, then use expression 1 .. else use expression 2

whatFruitToBuy = ( i like apples ) ? buy apples : buy grapes;

anyhow .. just saves some if/else statements.
sde is offline   Reply With Quote