Are there null like thing in solidity

前端 未结 5 1912
旧巷少年郎
旧巷少年郎 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:07

    In solidity every variable is set to 0 by default.

    You should think of mappings as all possible combinations are set to 0 by default.

    In your specific case I would use the following:

    if (buyers[msg.sender].amount == 0)
    

提交回复
热议问题