Swift超級新手,請耐心等待。錯誤:'_'不能轉換爲'StringLiteralConvertible'
我在REPL,施展出了我認爲是一個簡單的數據結構,如下:
var stuff = [
[
"id" : "A9AD6748-62A1-47E9-B0F7-2CF9B9C138EE",
"label" : "My Cool Label",
"things" : [
"1st string",
"2nd string",
"3rd string"
]
],
[
"id" : "9C7882A7-E40C-421F-BEDB-8C0249A768E3",
"label" : "Another Cool Label",
"things" : [
"4th string",
"5th string",
"6th string"
]
]
]
斯威夫特抱怨它以下列方式:
repl.swift:72:13: error: '_' is not convertible to 'StringLiteralConvertible'
"id" : "A9AD6748-62A1-47E9-B0F7-2CF9B9C138EE",
^~~~
repl.swift:70:17: error: type of expression is ambiguous without more context
var stuff = [
^
我不沒辦法。我的代碼中沒有_
。是混合類型(字符串和數組)的問題?
什麼是創建這種結構的正確方法?
在這種情況下,'_'是指未知的推斷類型。 – porglezomp