如何解决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;
它分配:
-
_anotherUint
到_initialSupply
的值(覆盖构造函数中传递的值) -
_initialSupply
到anotherUint
的(新)值 -
anotherUint
到totalSupply
的值 - 最后是
totalSupply
的值到balances[msg.sender]
(或在我的 JS 代码中到balance
)
Solidity 文档似乎没有涵盖这个主题,但它并不只对 Solidity 明确。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。