简体   繁体   English

什么意思表达“变量名;” 在 Solidity 中?

[英]What does mean expression "variableName;" in Solidity?

I can not find any information about this expression in docs.我在文档中找不到有关此表达式的任何信息。 There is the following code on Ehternaut Re-entrancy task . Ehternaut Re-entrancy task有以下代码。

function withdraw(uint _amount) public {
  if(balances[msg.sender] >= _amount) {
    (bool result,) = msg.sender.call{value:_amount}("");
    if(result) {
      _amount;
    }
    balances[msg.sender] -= _amount;
  }
}

What does _amount; _amount;是什么意思? mean?意思是?

if(result) {
  _amount;
}

This snippet effectively does nothing.这个片段实际上什么都不做。 You can safely ignore it, as it's not related to the reentrancy vulnerability.您可以放心地忽略它,因为它与重入漏洞无关。

Without the mentioned snippet, the compiler would raise a warning about unused result variable.如果没有提到的代码段,编译器会发出关于未使用的result变量的警告。 If they didn't declare the result variable, there would be another warning about not checking the result of the low-level call.如果他们没有声明result变量,则会有另一个关于不检查低级调用结果的警告。 And if they just left the condition block empty - yes, another warning about empty block.如果他们只是将条件块留空 - 是的,另一个关于空块的警告。

So my best guess is that the authors just wanted to clear the warnings, and chose this way to do that.所以我最好的猜测是作者只是想清除警告,并选择这种方式来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM