Lessons

lesson 08 / 15

For loops

A for loop binds one item at a time to a variable. The loop body can access global variables and use normal interpolation.

kongue
packages:
    - "kpkg"
    - "kosh"
    - "jumpstart"

main {
    for package in packages {
        print "building $package"
    }
}

Inline list literals can be useful for short, local lists.

kongue
main {
    for shell in ["kosh", "bash", "zsh"] {
        print "checking $shell"
    }
}