Avatar
swiftbot BOT 6/7/2018 2:21 PM
Author icon
tarunon
extension Sequence { public func compact<T>() -> [T] where Element == Optional<T> { return _compactMap { $0 } } } let a: [Int?] = [nil, 2, 3, nil, 5] let b: [Int] = a.compact().compact() print(b)
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:8:28: error: generic parameter 'T' could not be inferred let b: [Int] = a.compact().compact() ^