gpt4 book ai didi

ios - Swift 中的嵌套字典

转载 作者:搜寻专家 更新时间:2023-11-01 05:51:28 25 4
gpt4 key购买 nike

这段代码有什么问题,我该如何解决?请解释你的答案,所以我可以学习。我是 Swift 的新手,也是编程的新手。

var has: Dictionary<String, Dictionary<Dictionary, Int>> = [
"Material" : [
"Factory" : 0,
"Raw" : 0,
"Energy" : 0,
],
"Workers" : [
"Dev" : 0,
"Builder" : 0,
"Advertiser" : 0,
"Consultant" : 0,
"Engenier" : 0,
"QA" : 0,
],
"Assets" : [
"Bonds" : 0,
],
"Owe" : [
"10%" = 0,
"20%" = 0,
"30%" = 0
],
"Other" : [
"Insurance" : 0
]
]

最佳答案

您已将类型声明为 Dictionary<String, Dictionary<Dictionary, Int>> , 但文字实际上是 Dictionary<String, Dictionary<String, Int>> .这也是非法语法:

"Owe" : [
"10%" = 0,
"20%" = 0,
"30%" = 0
],

应该是:

"Owe" : [
"10%" : 0,
"20%" : 0,
"30%" : 0
],

关于ios - Swift 中的嵌套字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26958246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com