Solidity函数返回多个值及接收方式

在Solidity中定义多返回值的函数,并且如何获取参数。

pragma solidity ^0.5.10;

contract ManyReturns{

    // 基础方法:返回多个参数,用于被调用
    function getThreeNum() public returns(uint one,uint two, uint three){
        uint one = 1;
        uint two = 2;
        uint three = 3;
        return(one,two,three);
    }

    // 场景一:接收全部参数
    function call() public {
        uint one;
        uint two;
        uint three;
        // 接收结果的变量必须实现定义完成
        (one,two,three) = getThreeNum();
    }

    // 场景二:接收部分参数
    function call1() public{
        uint one;
        uint two;
        // 定义部分参数进行接收,未接收的参数,直接用逗号","分割即可。
        (one,two,) = getThreeNum();
    }
}

原文链接:《Solidity函数返回(returns)多个值及接收方式