GOLF(2gg)
β¨ NAME β¨
code-blocks β Golf documentation, the program-flow edition π«Ά
this is one page out of the GOLF(2gg) manual, and honestly it's a glow-up for your scope game π
πΈ DESCRIPTION πΈ
π CODE BLOCKS π
okay so bestie, you wanna group a bunch of statements together? say less. Use curly braces β { and } β to open and close a code block π«
Here's the tea: a code block creates a separate scope for previously non-existing variables defined within them, and that scope begins with { and ends with }. iykyk.
β οΈ and listen β if a variable already existed in an outer scope, it cannot be created in the inner scope. no cap, that's just how it is π
alsoooo, a bunch of statements come with implicit code blocks built right in β if-true, run-query, start-loop and read-line. which means the code between them and the accompanying end-statement is sitting inside implicit { and }. sneaky but iconic π§
π¦ EXAMPLES π¦
okay so this code right here first prints out "outside" and then "inside" twice, and it's illustrating the fact that variable s1 is defined only in the outer scope once. Variable s2 exists only in inner scope π
begin-handler /scope public
@<<print-out s1>>
set-string s1="outside"
{
set-string s2="inner variable"
set-string s1="inside"
@<<print-out s1>>
}
@<<print-out s1>>
end-handler
not me showing you the receipts with a whole runnable example π ate and left no crumbs fr fr
π SEE ALSO π
- Program flow
and the rest of the squad, go check them out:
break-loopcall-handlercode-blockscontinue-loopdo-onceexit-handlerif-definedif-truequit-processreturn-handlerstart-loop- See all documentation
this page is living in the $VERSION era, dated $DATE, and it's part of the GOLF(2gg) manual β Development section, obviously π mwah, go read some more pages bestie, ily πβ¨
π¦ 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