• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Short Circuit Evaluations option

B

benamas

Guest
Try as I might, I can't find how to enable short-circuit evaluations in Gamemaker Studio 2

In 1.4 it's right on the first tab of the Global Game Settings, which is visible right at the bottom of the resource tree; cool!

In 2, I've checked:
Game Options - Main
Game Options - Windows
and every tab of the IDE's Preferences dialog

Has this feature been removed? It's pretty obnoxious to have it on by default in 1.4 and then off (or completely unavailable??) in its supposed successor.

I'm having a very frustrating time with this; I know S2dio is still in beta, but it's not been a fun transition so far.
 
B

benamas

Guest
You're right; something else was wrong in the same line of code and I misinterpreted the error messages! Thank you!
 

Carsten

Member
Hello,

is there a way to turn this off in GMS2? I understand the benefit, but I often check for multiple options in a if clause (see example below) and if the first check is wrong, ...

val = 1;

if(val == 0 || val == 1){
// do something

This would no longer "do something" if val == 1, right?

Thanks, Carsten
 

FrostyCat

Redemption Seeker
is there a way to turn this off in GMS2? I understand the benefit, but I often check for multiple options in a if clause (see example below) and if the first check is wrong, ...

val = 1;

if(val == 0 || val == 1){
// do something

This would no longer "do something" if val == 1, right?
You have an incomplete understanding of what short circuiting does. You know only the && side, but not the || side.
  • When the operator is && and the first operand is false, it returns false without evaluating the second operand. Otherwise it continues evaluating the second operand.
  • When the operator is || and the first operand is true, it returns true without evaluating the second operand. Otherwise it continues evaluating the second operand.
Your operator is ||. The first operand is false, so it will continue to evaluate the second operand val == 1 and get true from it. The result will still "do something".

And please, create your own topic instead of bumping one up from 3 years ago.
 
Top