Return value of a function

The return value is the value of the output argument when the function call is finished. So no explicit "return value" statement is needed. Since the output argument is a local variable, it is initialized to null in the beginning of the function call. If output variable is never reset during the function call, then null will be returned. Of course, usually it should be assigned a value.

If a function does not intend to return any value, then there is no need to specify the output argument variable. The header of the function should look like

f = function x -> ()
       ...
       ...
    end
In this case, the function call f(x) still returns the null value back to the caller. (the null value is equal to an empty list, or an empty matrix, represented the symbol (), or []).



oz 2009-12-22