Given:
let maybeNumbers: [Int?] = [1,2,3,nil,5]
let numbers = maybeNumbers.flatMap { $0 }
print(numbers)
=> [1, 2, 3, 5]
Where flatMap on a SequenceType is said to:
Return an Array containing the non-nil results of mapping transform over self.
- cite