Created
July 23, 2014 17:53
-
-
Save marcprux/54b14b8906ebeb74d451 to your computer and use it in GitHub Desktop.
Create array of instances by unwrapping optionals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// converts an array of optionals to an array of non-optionals by filtering out nil | |
public func nilter<T>(var array: Array<Optional<T>>) -> Array<T> { | |
return array.filter { $0.getLogicValue() }.map { $0! } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment