![](/img/trans.png)
[英]Swift: Cannot convert value of type '[Any]' to specified type 'NSString'
[英]Swift: Cannot convert value of type '()' to specified type on init
我有 Struct init 並且我正在嘗試過濾 init 中的數組:
public struct doSomething: Codable {
public var listOfStuff: [String]
init(someStuff: [String]) {
var clone = someStuff
let stuff: [String] = clone.removeAll { $0 == "myName"}
listOfStuff = stuff
}
}
在這一行let stuff: [String] = clone.removeAll { $0 == "myName"}
我收到這個錯誤:
error: cannot convert value of type '()' to specified type '[String]
你們中的任何人都知道為什么我會收到此錯誤,或者您是否知道解決方法?
我會非常感謝你的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.