Are there null like thing in solidity

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

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


        
5条回答
  •  萌比男神i
    2021-02-05 06:12

    Instead of using one of the values or creating an extra boolean, you can check for the byte size of the structure.

    if (bytes(buyers[msg.sender]).length > 0) {
        // buyer exists.
    }
    

提交回复
热议问题