Functions that return values

Some functions are designed to perform a calculation or determine the condition of an object. Such functions create information, such as the result of the calculation or the state of the object. When one of these functions is finished executing, it “returns” this information.

For example, consider the function named Number.sqrt(). This function calculates the square root of any value you pass to it. For example, if you want to find out the square root of the number 25, you could indicate this as “Number.sqrt(25)”.

However, “Number.sqrt(25)” is not a complete expression, because it doesn’t tell an interactive presentation what to do with the returned value (the square root of 25, or 5). To create a complete expression, you have to tell the interactive presentation where to place the information.

One way to do this is to place it into a variable:

IntVar = Number.sqrt(25)

After this expression has been evaluated, IntVar will be equal to 5.

Note: Why does this function start with Number? In this case, Number simply indicates that this function is a numerical function. For more information, see “Objects.”

Functions that return values