REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 3-Aug-2010 Edit History |
Catches a throw from a block and returns its value.
Arguments:
block [block!] - Block to evaluate
Refinements:
/name - Catches a named throw
word [word! block!] - One or more names
/quit - Special catch for QUIT native
See also:
catch and throw go together. They provide a way to exit 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, it will return from the catch at that point.
The result of the catch will be whatever was passed as the argument to the throw.
write %file.txt "i am a happy little file with no real purpose"
print catch [
if exists? %file.txt [throw "Doc found"]
"Doc not found"
]
Doc not found
When using multiple catch functions, provide them with a name using the /name refinement to identify which one will catch which throw.
Editor note: Example with /name
Editor note: Example of using catch in a function spec.
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |