returns the value expr from a function.


returns the value Null.


  • Return[expr] exits control structures within the definition of a function, and gives the value expr for the whole function.
  • Return takes effect as soon as it is evaluated, even if it appears inside other functions.
  • Return can be used inside functions like Scan.


open allclose all

Basic Examples  (1)

Return from a function:

Possible Issues  (1)

Return exits only the innermost construct in which it is invoked:

Here it exits the Do loop, but not the function g:

Use Catch and Throw for explicit flow control:

Introduced in 1988
Updated in 1996