Skip to content

Instantly share code, notes, and snippets.

@marcprux
Created July 23, 2014 17:53
Show Gist options
  • Save marcprux/54b14b8906ebeb74d451 to your computer and use it in GitHub Desktop.
Save marcprux/54b14b8906ebeb74d451 to your computer and use it in GitHub Desktop.
Create array of instances by unwrapping optionals
/// 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