Solidity
收到警告:solidity-unnamed-return-variable-can-remain-unassigned
// SPDX-License-Identifier: GPL-3.0-or-other pragma solidity >= 0.7.0 < 0.9.0; contract Factorial { uint num; constructor () { num = 0; } function setNumber (uint newNum) public { num = newNum; } function findFactorial () public returns (uint) { uint fact = 1; while (num > 0) { fact = fact * num; num--; } return fact; } }
我沒有看到以下程式碼的任何警告(在 Remix 上測試):
// SPDX-License-Identifier: GPL-3.0-or-other pragma solidity >= 0.7.0 < 0.9.0; contract Factorial { uint num; constructor () { num = 0; } function setNumber (uint newNum) public { num = newNum; } function findFactorial () public returns (uint) { uint fact = 1; while (num > 0) { fact = fact * num; num--; } return fact; } }
我沒有看到以下程式碼的任何警告(在 Remix 上測試):