GOLF(2gg)

NAME
code-blocks - Golf documentation (program-flow)

DESCRIPTION

CODE BLOCKS

Use curly braces ("{" and "}") to open and close a code block. They create a separate scope for previously non-existing variables defined within them, which begins with "{" and ends with "}". Note that if a variable existed in an outer scope, it cannot be created in the inner scope.

Note that if-true, run-query, start-loop and read-line statements contain implicit code blocks, meaning the code between them and the accompanying end-statement is within implicit "{" and "}".

EXAMPLES
The following code will first print out "outside" and then "inside" twice, 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

SEE ALSO
 Program flow

break-loop call-handler code-blocks continue-loop do-once exit-handler if-defined if-true quit-process return-handler start-loop See all documentation