GOLF(2gg)
πΈ NAME πΈ
if-true β the (program-flow) girlie herself β¨ she's the conditional statement, the moment where your code gets to choose its own destiny π
π PURPOSE π
Conditional statement. That's it, that's the whole job, and she ate π
π SYNTAX π
okay bestie, here's the shape of her π
if-true <condition>
<any code>
[
else-if <condition>
<any code>
] ...
[
else-if
<any code>
]
end-if
where <condition> is:
( <comparison> [ and <comparison> [ , ... ] ] )
|
( <comparison> [ or <comparison> [ , ... ] ] )
<comparison> is for strings:
<string> \
( equal | not-equal | \
lesser-than | lesser-equal | \
greater-than | greater-equal | \
contain | not-contain ) \
<check string> \
[ case-insensitive ] [ length <length> ]
<comparison> is for numbers
<number> \
( equal | not-equal | \
lesser-than | lesser-equal | \
greater-than | greater-equal | \
every | not-every ) \
<check number> ...
<comparison> is for booleans:
<boolean> ( equal | not-equal ) <check boolean> ...
π¦ DESCRIPTION π¦
So like, if-true evaluates a <condition> and then runs whatever code matches it. If the <condition> sitting inside if-true or inside an else-if succeeds, then the <any code> hanging out right below it gets executed. If it's not a match, then the next condition in the else-if statement gets evaluated β one by one, bestie, in order β until something matches and the code under that statement runs. And if nothing matches? Then the code under the else-if statement that has no <condition> runs (only if you actually wrote one, though π). Otherwise, program control just passes on outside of end-if. Bye π
A <condition> is made of one or more <comparison>s, connected by either an and clause or an or clause β but not both in the same <condition>, that's the rule, no cap. The and clause uses logical AND to link <comparison>s together, and it succeeds if all of them succeed. The or clause uses logical OR to link them, and it succeeds if at least one of them succeeds β and the moment one of them hits, the rest don't even get checked, she's efficient like that π
Every single <comparison> looks at either a string, a number, or a boolean variable. Pick your fighter β¨
π STRING VARIABLE IN A COMPARISON
If the equal, not-equal, lesser-than, lesser-equal, greater-than or greater-equal clause is used, the comparison succeeds if <string> is equal to, not equal to, lesser than, lesser than or equal to, greater than, or greater than or equal to <check string>, respectively. (Yes, in that exact order, they line up perfectly, it's giving choreography π©°)
If the contain or not-contain clause is used, the comparison succeeds if <string> is contained in, or not contained in, <check string>, respectively.
If case-insensitive is used, the comparison goes down without case sensitivity β vibes only, no shouting matters.
If the length clause is used, only the first <length> bytes of the strings get compared. Just the first <length> bytes. That's it π
π NUMBER VARIABLE IN A COMPARISON
If the equal, not-equal, lesser-than, lesser-equal, greater-than or greater-equal clause is used, the comparison succeeds if <number> is equal to, not equal to, lesser than, lesser than or equal to, greater than, or greater than or equal to <check number>, respectively.
If every is used, then the comparison succeeds when the modulo of <number> and <check number> is 0 β which is iconic for running some code every N times but not the ones in between. And with not-every, the comparison succeeds when that modulo is not 0, which is exactly what you want when you're running code all the times except every Nth. Balanced, as all things should be β
π BOOLEAN VARIABLE IN A COMPARISON
If the equal or not-equal clause is used, the comparison succeeds if <boolean> is equal to, or not equal to, <check boolean>, respectively. Simple, clean, no notes π
π§ ELSE-IF WITHOUT A <CONDITION>
With a given if-true, there can be only one else-if statement without a condition, and it must be the last one. The final girl energy is real, she goes last and only one of her is allowed π
π₯ NESTING
if-true can be nested, and it can go up to 30 levels deep π dream within a dream within a dream, bestie.
π EXAMPLES π
%% /if-test public
get-param inp
if-true inp equal "1"
@Found "1" in input
else-if inp equal "2" or inp equal "3"
@Found "2" or "3" in input
get-param inp_num
string-number inp_num to num
if-true num equal 4
@Found 4 in more input
else-if num equal 5 and inp equal "4"
@Found 5 in more input and "4" in input
else-if
@Something else
end-if
else-if
@Found something else
end-if
%%
π SEE ALSO π
Program flow β the whole squad π
break-loopcall-handlercode-blockscontinue-loopdo-onceexit-handlerif-definedif-truequit-processreturn-handlerstart-loop- See all documentation π
and that's the tea π« this page came to you from $DATE and version $VERSION, living under the GOLF(2gg) banner β go forth and branch, bestie, you got this πβ¨π¦π
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms