Skip to content

return

Return from a procedure with a value or special control flow.

Syntax

tcl
return ?options? ?value?

Parameters

  • value: The value to return. Defaults to empty string.

Options

  • -code code: Return code. Can be:
    • ok (0) - Normal return
    • error (1) - Raise an error
    • return (2) - Cause calling proc to return
    • break (3) - Break from loop in caller
    • continue (4) - Continue loop in caller
    • Or any integer
  • -level level: Number of stack levels to return through
  • -options dict: Dictionary of return options

Examples

Basic return

Output

Early return

Output

Return without value

Output

Returning from nested procedures

Output

Return with error code

Output

See Also