Is there are better way to do this? Something that looks nicer syntax wise?
let a : [Any] = [5,"a",6]
for item in a {
if let assumedItem = item as? Int {
print(assumedItem)
}
}
Something like this, but then with the correct syntax?
for let item in a as? Int { print(item) }
If you're using Swift 2:
let array: [Any] = [5,"a",6]
for case let item as Int in array {
print(item)
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加