Created
May 30, 2019 00:39
-
-
Save Qata/46bc0c4bb0272cb53660d460c617a691 to your computer and use it in GitHub Desktop.
This file contains 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
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