Skip to content

Instantly share code, notes, and snippets.

@Qata
Created May 30, 2019 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qata/46bc0c4bb0272cb53660d460c617a691 to your computer and use it in GitHub Desktop.
Save Qata/46bc0c4bb0272cb53660d460c617a691 to your computer and use it in GitHub Desktop.
extension Optional {
func filter(_ isIncluded: (Wrapped) throws -> Bool) rethrows -> Optional<Wrapped> {
switch self {
case let value? where try isIncluded(value):
return value
default:
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment