Solidity 솔리디티 강좌 29강 : 함수 리턴값 변수 명시

flowing1ife·2023년 8월 2일
0

[ Solidity 깨부수기 ]

목록 보기
29/29
post-thumbnail

Solidity 솔리디티 강좌 29강 : 함수 리턴값 변수 명시
이번엔 solidity의 함수 리턴값 변수를 명시하는 방법에 대해 알아보도록 하자.


함수 리턴값 변수 명시

📌 Solidity

// SPDX-License-Identifier: GPL-3.0
pragma solidity >= 0.7.0 < 0.9.0;

contract lec29{
    function add1(uint256 _num1, uint256 _num2)public pure returns (uint256){
        uint256 total = _num1 + _num2;
        return total ;
    }

  // 함수 리턴값 변수 명시
    function add2(uint256 _num1, uint256 _num2)public pure returns (uint256 total){
        total = _num1 + _num2;
        return total ;
    }
}

위와 같이 함수 리턴값 변수를 명시할 수 있다.

👉 결과

결과를 보면 함수 리턴값을 명시한 add2 함수에는 total이 10이라고 명시된다.


출처 및 참고 자료

profile
👩🏻‍💻 Backend Engineer, Contract Developer

0개의 댓글