Created
April 12, 2017 20:17
-
-
Save macbellingrath/ceab3cba75d57bb94ac0311de3e135a3 to your computer and use it in GitHub Desktop.
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
extension Optional { | |
func flatMapWith<T, U>(_ other: T?, _ transform: (Wrapped, T) -> U?) -> U? { | |
guard case .some(let `self`) = self else { | |
return nil | |
} | |
guard let element = other else { | |
return nil | |
} | |
return transform(self, element) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment