What does this code do?
Im lost on the ? and : signs?
Code:return(num1>num2 ? num1 : num2);
Printable View
What does this code do?
Im lost on the ? and : signs?
Code:return(num1>num2 ? num1 : num2);
The ?: operator is merely shorthand:
Here's the syntax:Code:string x;
int y = 4
x = ((y > 4) ? "Y greater than 4" : "Y not greater than 4");
Code:result = (comparison) ? true-result : false-result
If num1>num2 then num1 is returned else if num1<num2 then num2 is returned.
That means thet if the expression is true the first value is returned else the second is retuned.
Little late...
Hehe n/p ;)
<<< burns back from holiday to answer questions :p