solidity基础-数组和枚举

数组

例子

contract ArrayTest {

    uint256[] public array01;
    uint256[] public array02=[1,2,3];


    function push(uint256 i) public{
        array01.push(i);
    }

    function pop(uint256 i) public{
        array01.push(i);
    }

    function getArray() public view returns(uint256[] memory) {
        return array02;
    }    
}

部署

    

 

 

枚举

例子

contract EnumTest {

    enum Numbers{
        first,
        second
    }

    Numbers public num;

    function get() public view returns(Numbers){
        return num;
    }

    function set(Numbers _num) public{
        num = _num;
    }

}

输出

    

 

posted @ 2022-05-09 22:18  apeNote  阅读(113)  评论(0编辑  收藏  举报