August 2019
Intermediate to advanced
486 pages
13h 52m
English
In Solidity, from any type of function, you can return multiple values. You can do this by using the return(value1, value2, ...) statement or by directly assigning the value to the variable name that's used in the returns() statement.
The following is an example of returning multiple values from a function:
contract MultiReturn { function sum() public pure returns (uint) { //Receiving multi return from function (uint x, uint y) = getDataWithoutReturnStatement(); return x + y; } //Example to return multiple values using return statement function getDataWithReturnStatement() internal pure returns(uint, uint) { return (1, 2); } //Example to return multiple values without return statement function getDataWithoutReturnStatement() ...