ethereum(以太坊)(十三)--异常处理/元祖

Posted on 2018-11-20 11:33  eilinge  阅读(250)  评论(0编辑  收藏  举报
pragma solidity ^0.4.4;

contract Students{
    uint[] data= new uint[](4);
    
    address _owner = msg.sender;
    
    function get() constant returns(bool,uint,string,uint){
        return(true,1,'eilinge',3);
    }
    
    function f() constant returns(uint[]){
        (,data[2],,) = get();
        return data;
    }
    
    function f1() constant returns(uint,uint){
        require(_owner == msg.sender);
            var (,x,,y) = get();
            (x,y) = (y,x);
            return (x,y);
    }
    //require(_owner == msg.sender);
    //assert(_owner == msg.sender);
    //if (_owner != msg.sender){ revert;}
    //assert()/require():中的条件声明,是if例子中条件块的取反, ==代替了 !=;
}