I\'m trying to write an extension to Array which will allow an array of optional T\'s to be transformed into an array of non-optional T\'s.
e.g. this could be writte
If you are fortunate enough to be using Swift 4 then you can filter out nil values using compactMap
compactMap
array = array.compactMap { $0 }
E.g.
let array = [1, 2, nil, 4] let nonNilArray = array.compactMap { $0 } print(nonNilArray) // [1, 2, 4]