MATHEMATICA MESSAGE

Break::nofunc Continue::nofunc Return::nofunc

DetailsDetails

  • This message is generated when the optional second argument in Break, Continue, or Return does not match an enclosing function call.
  • The second argument in Break, Continue, or Return is a label that specifies the enclosing function or loop that will be affected. If this label is omitted, the affected function or loop is determined using built-in heuristics.
  • Off[message] switches off the message; On[message] switches it on. For example: Off[Break::nofunc].

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Return is used with two arguments and there are no enclosing functions:

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

This shows a typical use of Return with two arguments. The second argument is used here to specify that the return should be from the enclosing Module:

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

Without the second argument in Return, the default is to return from the enclosing Do loop, so the return value of the function will be different:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=

This shows an incorrect use of the second argument in Return. The function f does not enclose the Return expression and so cannot be used as a return destination.

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

Clear the definition of f:

In[3]:=
Click for copyable input
New to Mathematica? Find your learning path »
Have a question? Ask support »