如何判断在一个映射中是否存在某个键,Struct被定义在库中(在Solidity中)。

pragma solidity ^0.4.8;

library Library {
  struct data {
     unit val;
   }
}

-

contract Array{
    using Library for Library.data;
    mapping(address => Library.data) clusterContract;

    function addCluster(address id) returns(bool){
        if(clusterContract[id] == address(0) ){ //error occurs!
            clusterContract[id] = list;
            return true;
        }
        return false; 
    }
}

判断语句if(clusterContract[id] == address(0))给出了错误。错误如下所示:

Operator == not compatible with types struct Library.data storage ref and address
E               if(clusterContract[id] == address(0) ){...

请问:我该怎么解决这个错误呢?

谢谢你宝贵的时间和帮助。

请先 登录 后评论

1 个回答

不凡
请先 登录 后评论