A mark question
by David Tan · in Torque Game Engine · 08/31/2004 (8:43 pm) · 2 replies
I am a newbie,I have a question,what do the mark "?" mean in the follow code:
thanks.
Quote:
function turnRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
thanks.
Torque Owner Drew Hitchcock
basically, it follows the form:
what this means is that if "condition" is true, execute statement1, if "condition" is false, execute statement2.
In the example you gave, $mvYawLeftSpeed will be set equal to $pref::Input::KeyboardTurnSpeed if %val is non-zero and it will be set to 0 otherwise.
It's late, so rather than having me try to explain any further, here's a more comprehensive and possibly more confusing article from MSDN.
The Conditional Operator (? :)