此代码有什么问题,我该如何解决这个问题? 请解释一下你的答案,这样我就可以学习。我是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
]
]
答案 0 :(得分:8)
您已将类型声明为Dictionary<String, Dictionary<Dictionary, Int>>
,但文字实际上是Dictionary<String, Dictionary<String, Int>>
。这也是非法语法:
"Owe" : [
"10%" = 0,
"20%" = 0,
"30%" = 0
],
应该是:
"Owe" : [
"10%" : 0,
"20%" : 0,
"30%" : 0
],