【问题标题】:What does ! mean in Solidity?有什么作用!在 Solidity 中是什么意思?
【发布时间】:2019-08-12 08:55:19
【问题描述】:

我正在学习 Solidity,但我无法理解 ⑨⑫⑬ 中的 [!] 是什么意思。

这是什么意思?还有,怎么用?

请给点建议好吗?

function sendReward(uint256 _reward, address _dest, uint256 _id) external 
  onlyOwner {
        require(!rewardSent[_id]); // ⑨
        require(_reward > 0); // ⑩
        require(address(this).balance >= _reward); // ⑪
        require(_dest != address(0)); // ⑫
        require(_dest != owner); // ⑬
        rewardSent[_id] = true; // ⑨
        _dest.transfer(_reward);
        emit RewardSent(_dest, _reward, _id);
    }

【问题讨论】:

  • != 表示“不等于”
  • !foo 的意思是“不是foo”。

标签: blockchain ethereum solidity openzeppelin


【解决方案1】:

根据the documentation!=是不等式运算符。 以下行均计算为true

1 == 1
1 != 2 
1 != 3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-12
    • 2017-06-11
    • 2018-03-05
    • 2023-03-27
    • 1970-01-01
    • 2011-05-09
    • 2011-05-10
    • 2021-08-29
    相关资源
    最近更新 更多