Created
September 27, 2021 08:27
-
-
Save NikKovIos/f113c27bbff971680618ec2e83fcf1d5 to your computer and use it in GitHub Desktop.
Converting Optional Array to Optional Set
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 where Wrapped: Collection, Wrapped.Element: Hashable { | |
func transformToSet() -> Set<Wrapped.Element>? { | |
if let self = self { | |
return Set(self) | |
} else { | |
return nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment