Solidity,在同一行用“=”赋值多个值

Solidity, assigning multiple values with "=" in the same line

从哪里可以得到这个奇怪的 solidity 赋值的详细解释?

构造函数中的那个。多个 = = = .

在官方文档中找不到任何内容。

contract Token {

  mapping(address => uint) balances;
  uint public totalSupply;
  uint public anotherUint = 10;

  constructor(uint _initialSupply, uint _anotherUint) {
    balances[msg.sender] = totalSupply = anotherUint = _initialSupply = _anotherUint;
  }

  function transfer(address _to, uint _value) public returns (bool) {
    require(balances[msg.sender] - _value >= 0);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    return true;
  }

  function balanceOf(address _owner) public view returns (uint balance) {
    return balances[_owner];
  }
}

它是 chained assignment 的一个示例,可用于许多其他编程语言。

JS 示例:

// copy paste this to your browser devtools console to explore how it works

let _initialSupply = 5;
let _anotherUint = 10;
let anotherUint;
let totalSupply;

const balance = totalSupply = anotherUint = _initialSupply = _anotherUint;

它赋值:

  1. _anotherUint 的值到 _initialSupply(覆盖构造函数中传递的值)
  2. (新)值 _initialSupplyanotherUint
  3. anotherUinttotalSupply
  4. 的值
  5. 最后 totalSupply 的值到 balances[msg.sender] (或者在我的 JS 代码中到 balance

Solidity 文档似乎没有涵盖这个主题,但它并不明确仅针对 Solidity。