• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Functions > Functions That Return Values

Functions That Return Values

Currently we are using functions to run repetitive code using parameters, but all the functions are doing is running code. Now let's make them give back some information. To do this, we'll use the return statement.

The return statement does two things. First, when the interpreter reaches the return statement, it causes the function to end. Second, it returns the value of an expression assigned to it, but the expression is optional. Here is a generic template:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint