continue(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– continue β€” bestie edition πŸ’–

okay so this is continue(3tcl), straight out of the Tcl Built-In Commands lineup, and it's literally the "skip to the next one" button for your loops. tiny command, huge main character energy. ✨


🌸 NAME 🌸

continue β€” skip to the next iteration of a loop πŸŒ€


πŸŽ€ SYNOPSIS πŸŽ€

continue

that's it. that's the whole thing. no args, no flags, no drama. she's a one-word queen. πŸ‘‘


✨ DESCRIPTION ✨

so bestie, you usually call this one inside the body of a looping command β€” think for or foreach or while. πŸ’…

when you invoke it, continue returns a 4 (TCL_CONTINUE) result code, and that is what makes a continue exception happen. and what does that exception do? it aborts the current script and bounces it out to the innermost containing loop command, which then just... continues on with the next iteration of the loop. like nothing happened. iconic behaviour honestly. πŸ¦‹

and it's not only loops that deal with continue exceptions β€” they're also handled in a few other situations, like the catch command and the outermost scripts of procedure bodies. so iykyk, it shows up in more places than you'd expect. 🌈


πŸ“ EXAMPLE πŸ“

ok so imagine you wanna print a line for each of the integers from 0 to 10 except 5. rude to skip 5 but okay, we ball:

for {set x 0} {$x<10} {incr x} {
    if {$x == 5} {
        continue
    }
    puts "x is $x"
}

see how continue just nopes out of that one iteration and the loop keeps rolling? chef's kiss. πŸ˜­πŸ’–


🫢 SEE ALSO 🫢


πŸ‘‘ KEYWORDS πŸ‘‘

continue, iteration, loop


and that's the whole page, bestie β€” brought to you by Tcl and the manual page continue(3tcl). go skip some iterations, you got this. πŸ’œπŸ§šπŸŒΈ

πŸ“¦ where this page comes from