Multiple Return Values


Unlike C/C++, the SPL return function supports multiple return values. For example:



    return(x, x*x);


(a, b) = multi(10)


a == 10


b == 100



The ()'s are required for multi-value assignments. If a function returns N values but only N-P variables are supplied on the left hand side of the assignment, the remaining return values are discarded. Likewise, if a function returns N values and N+P assignment variables are supplied, only N assignments occur.