REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: throw

throw  value  /name  word

Throws control back to a previous catch.

Arguments:

value [any-type!] - Value returned from catch

Refinements:

/name - Throws to a named catch

word [word!]

See also:

catch   return   exit  

Description

CATCH and THROW go together. They provide a method of exiting from a block without evaluating the rest of the block. To use it, provide CATCH with a block to evaluate. If within that block a THROW is evaluated, the script will return from the CATCH at that point. The result of the CATCH will be the value that was passed as the argument to the THROW. When using multiple CATCH functions, provide them with a name to identify which one will CATCH which THROW.

print catch [
    if exists? %file.txt [throw "Doc file!"]
]
none


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin