Use of the "?"

What does the mentioned command do? In this example, what does it contribute?

string sBridge = asEntity=="bridge_lever_1" ? "bridge_metal_vert_1": "bridge_metal_vert_2";

Last edited on
? is the conditional operator.

If the equation to the left of the ? evaluates to true, then it will return the first value (which in this case will store the value 'bridge_metal_vert_1' into the string sBridge. If the equation to the left of the ? evaluates to false then it returns the 2nd value which would be bridge_metal_vert_2 .

It is shown here as well.
http://www.cplusplus.com/doc/tutorial/operators/
I understand! Thanks for the reply man.

I guess I should have been able to find it, but I didn't know whether "?" was a command, or operator or w/e.
Topic archived. No new replies allowed.