|
I don't exactly get it since, let's say we have :
temp.var = 5;
player.chat = "Number"SPC (temp.var ? "is correct" : "is false");
I don't see how they can know that it's "if (temp.var == 5)" or not == 4. Is it used for booleans only? (true / false)?
|
as tricxta said, its
PHP Code:
(condition ? condition_true : condition_false);
just like
PHP Code:
if (condition) {
condition_is_true_stuff;
}
else {
condition_is_false_stuff;
}
the
condition can be just like in
if() checks. so you can go from
if (something_is_true/false) ....,
if (something == something else) ....,
if (something != something else) ...., ... . its good to use the
? if you got short checks or want to call functions, like
PHP Code:
temp.number = 5;
player.chat = "the number is 5? " @ (temp.number == 5 ? "yes!" : "no!");
//instead of
temp.number = 5;
if (temp.number == 5) player.chat = "the number is 5? yes!";
else player.chat = "the number is 5? no!"
//or
temp.invalid_speed = true;
temp.invalid_speed ? speedFix() : anotherFunction();
//instead of
temp.invalid_speed = true;
if (temp.invalid_speed) speedFix();
else anotherFunction();