0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Solidity】(tips)関数に対して複数の値を受け取る方法

Posted at

今回は関数に対して複数の値を受け取る方法を下記します。
2つの数字を引数として渡すと、その値をそれぞれ返す関数numと
numの関数から値を受け取り、その数字を足す関数exNumを定義します。
関数exNum内で、num関数の値を受けとるためには(型 変数名, 型 変数名)で定義します。

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract Sample{
    function num(uint _a, uint _b)internal pure returns(uint, uint){
       return (_a, _b);
    }
    //
    function exNum(uint _s, uint _t)public pure returns(uint){
        (uint number1, uint number2) = num(_s, _t);
        return number1 + number2;
    }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?