Return

Return[expr]

returns the value expr from a function.

Return[]

returns the value Null.

Details

  • 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.

Examples

open allclose all

Basic Examples  (1)

Return from a function:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Possible Issues  (1)

See Also

Break  Throw  Abort  DialogReturn

Tutorials

Introduced in 1988
(1.0)
| Updated in 1996
(3.0)