Solidity,在同一行中用“=”分配多个值

问题描述

我在哪里可以获得关于 solidity 这个奇怪任务的详细解释?

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

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

{
    "Subscriptions": [
        {
            "SubscriptionArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt:ccffgv-e904-4f68-9a8f-vvggbb","Owner": "xxxxxxx","Protocol": "email","Endpoint": "qwerty@amazon.com","TopicArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt"
        },{
            "SubscriptionArn": "PendingConfirmation","Endpoint": "qwer@amazo.com","Endpoint": "qwettet@amazn.com","TopicArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt"
        }`cv`
    ]
}

解决方法

这是 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. 最后是 totalSupply 的值到 balances[msg.sender](或在我的 JS 代码中到 balance

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