I\'m a little confused around flatMap (added to Swift 1.2)
Say I have an array of some optional type e.g.
let possibles:[Int?] = [nil, 1, 2, 3, nil, nil
You could use reduce:
reduce
let flattened = possibles.reduce([Int]()) { if let x = $1 { return $0 + [x] } else { return $0 } }
You are still kind of declaring the type, but it's slightly less obtrusive.