samspade
Member
I have a question about the evaluation order of if statements. I have been using statements like:
in code rather than:
because the first form was easier for me to read and saved on indentation. I tested it and it wasn't giving me an error if the instance didn't exist so I assumed that it evaluated the if statement in order and (at least for an &&) therefore wouldn't check the second half of the if statement if the first half returned false.
However, I was reading the help manual about evaluation order and it seems like this may not be true on all platforms. Should I always use the second ordering or are the two forms identical?
Code:
if (instance_exists(target)) && (distance_to_object(target) < range) {
/* do something */
}
Code:
if (instance_exists(target)) {
if (distance_to_object(target) < range) {
/* do something */
}
}
However, I was reading the help manual about evaluation order and it seems like this may not be true on all platforms. Should I always use the second ordering or are the two forms identical?