This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Return

Return[expr]
returns the value expr from a function.
Return
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 from a function:
Return from a function:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
Return exits only the innermost construct in which it is invoked:
Here it exits the Do loop, but not the function :
Use Catch and Throw for explicit flow control:
New in 1 | Last modified in 3