Lessons

lesson 09 / 15

continue and break

Use continue to skip the rest of the current iteration. Use break to leave the loop.

kongue
packages:
    - "kpkg"
    - "skip-me"
    - "kosh"
    - "stop-here"
    - "jumpstart"

main {
    for package in packages {
        if "$package" == "skip-me" {
            continue
        }
        if "$package" == "stop-here" {
            break
        }
        print "processing $package"
    }
}

The output contains kpkg and kosh. It does not contain skip-me or jumpstart.