\section{RETURN Return From Function}

\subsection{Usage}

The \verb|return| statement is used to immediately return from
a function, or to return from a \verb|keyboard| session.  The 
syntax for its use is
\begin{verbatim}
  return
\end{verbatim}
Inside a function, a \verb|return| statement causes FreeMat
to exit the function immediately.  When a \verb|keyboard| session
is active, the \verb|return| statement causes execution to
resume where the \verb|keyboard| session started.
\subsection{Example}

In the first example, we define a function that uses a
\verb|return| to exit the function if a certain test condition 
is satisfied.
\begin{verbatim}
    return_func.m
function ret = return_func(a,b)
  ret = 'a is greater';
  if (a > b)
    return;
  end
  ret = 'b is greater';
  printf('finishing up...\n');
\end{verbatim}
Next we exercise the function with a few simple test
cases:
\begin{verbatim}
--> return_func(1,3)
finishing up...
ans = 
  <string>  - size: [1 12]
 b is greater
--> return_func(5,2)
ans = 
  <string>  - size: [1 12]
 a is greater

\end{verbatim}
In the second example, we take the function and rewrite
it to use a \verb|keyboard| statement inside the \verb|if| statement.
\begin{verbatim}
    return_func2.m
function ret = return_func2(a,b)
  if (a > b)
     ret = 'a is greater';
     keyboard;
  else
     ret = 'b is greater';
  end
  printf('finishing up...\n');
\end{verbatim}
Now, we call the function with a larger first argument, which
triggers the \verb|keyboard| session.  After verifying a few
values inside the \verb|keyboard| session, we issue a \verb|return|
statement to resume execution.
\begin{verbatim}
--> return_func2(2,4)
finishing up...
ans = 
  <string>  - size: [1 12]
 b is greater
--> return_func2(5,1)
[return_func2,4]--> ret
ans = 
  <string>  - size: [1 12]
 a is greater
[return_func2,4]--> a
ans = 
  <int32>  - size: [1 1]
 5  
[return_func2,4]--> b
ans = 
  <int32>  - size: [1 1]
 1  
[return_func2,4]--> return
finishing up...
ans = 
  <string>  - size: [1 12]
 a is greater

\end{verbatim}
