Are there null like thing in solidity

前端 未结 5 1931
旧巷少年郎
旧巷少年郎 2021-02-05 05:33
    struct buyer{
       uint amount;
       Status status;
    }

    mapping(address=>buyer) public buyers;
    mapping(uint=>address) buyerIndex;
    uint publi         


        
5条回答
  •  余生分开走
    2021-02-05 06:23

    There is nothing like null in solidity.

    Just check for the length of the address:

    if(buyers[msg.sender].length == 0){
        // do your thing
    }
    

    See also this answer on ethereum stack exchange.

提交回复
热议问题