0
我試圖做到這一點:雨燕「無法下標類型的值」的錯誤
self.prepared[$0]
已配製是Dictionary<String, (String, Size)>
一個實例,而$ 0是String
。
任何想法任何人 - 我不知道爲什麼這不能被下標。
(完整的錯誤是這樣的:error: cannot subscript a value of type 'inout PreparedImageResponses' (aka 'inout Dictionary<String, ProductImageResponse>')
其中PreparedImageResponses是[String: (String, Size)]
一個typealias和ProductImageResponse是一個元組(String, Size)
(大小的typealias只是一個struct)
我不能再現這個,請提供一個[mcve] – Hamish
令人討厭的是,我在操場上做的任何小例子都是絕對沒問題的。我開始認爲這是一個Swift編譯器輸出錯誤 - 我認爲我的錯誤是在別的地方,這只是它的一個副作用。 – deanWombourne
我有時在這種情況下做了什麼,是將'$ 0'分配給一個局部變量,然後看看Swift對它做了什麼。也許'$ 0'實際上不是'String'?跛腳,我知道,但編譯器錯誤並不總是加起來,我發現.... – fguchelaar