Regarding the If Statement, which of the following is false?
A) The True and False branches are mandatory
B) Only one of the branches is executed, depending on the result of the If condition
C) If statements can also be used to implement loops
D) More branches can be added, if necessary
If statements can't repeat, so this is incorrect.
I think a switch statement would be more appropriate for the statement "More branches can be added," so this sentence is also incorrect.
So, are there two possible answers?
Why answer C is incorrect? What about something like this?
It works like a loop
You are right, answer C is correct, you can easily create what is generally called an ad hoc loop with an If.
Hello.
A lot of you don't know how to do an ad-hoc loop!
A) The True and False branches are mandatory Yes, both need to exist, even if with nothing on it.
B) Only one of the branches is executed, depending on the result of the If condition Yes, that is the point.
C) If statements can also be used to implement loops Yes, they are called ad-hoc loops.
D) More branches can be added, if necessary. You can't add branches to an If, only to a Switch.
More details on the ad-hoc loop:
OutSystems only has ForEach to do loops. The alternative to For and While loops is done with an If.
It will repeat a few times and them go away.
A) The True and False branches are mandatory – true
B) Only one of the branches is executed, depending on the result of the If condition – true
C) If statements can also be used to implement loops – false
D) More branches can be added, if necessary – misleading or partially false
If statements are for conditional branching, not iteration. You need a loop (e.g., for, while) to repeat actions.
If statements typically support two branches only: True and False.
If you want more than two conditions, you use nested ifs or a switch/case structure. So while you can simulate more branches, it's not that If natively supports them.
This statement is misleading and arguably false,
hi @TravelerAutumn
1) The True and False branches are mandatory : True : In OutSystems, an If node always has both a True and False connector.
2) Only one of the branches is executed, depending on the result of the If condition True : The condition is evaluated, and the flow continues only through one branch.
3) If statements can also be used to implement loops False : In OutSystems, an If is purely a conditional branch; it doesn’t create loops. Loops are implemented using a For Each or While node, not an If.
D) More branches can be added, if necessary True : You can chain multiple Ifs or use Switch-like patterns, though not in a single If node.
Correct Answer: C — An If statement in OutSystems cannot directly implement loops.
I hope this helps
Thanks
It is like Nuno said. Let me just ad that these ad-hoc loops have the potential to be "infinite loops" so always make sure the exit condition is reachable.
Eventually you will reach a timeout on the thread unless you are on a heavy timer that wakes itself up or similar - that should have a failsafe to break the loop easier.