Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Telix/SALT v3.15 & RS-232, Hayes - <b>return</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  RETURN

  At some time, every function must be exited. If the end of the func-
  tion is reached, control will automatically return to the calling
  function. Very often however, it is necessary to leave a function
  somewhere while only halfway through it, perhaps based on a condi-
  tional test. As well, it is often necessary that a function returns
  a value to the caller. The format of the return statement is:

       return <expression>;

  If the return statement is encountered anywhere in the function,
  control immediately returns to the function that called this func-
  tion. The expression is the value that should be returned. If no ex-
  pression is supplied, a dummy value is returned. The expression
  should match they type of value that the caller of this function is
  expecting. That is, if an 'int' type is expected, the expression
  should resolve to an integer value. If a 'str' type is expected, the
  expression should resolve to a string value. Due to memory con-
  straints, a local string variable may NOT be returned from a func-
  tion. Some examples are:

       return;
       return 1;
       return level;
       return (sum + 25);
       return "hello";
       return (func() + 20);

  Notice that when a complex expression is returned it is usually sur-
  rounded by parentheses. This is done only for clarity and is not
  necessary. Also, it should be clear that what is returned is not the
  expression but what it evaluates to.

See Also: functions

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson