Skip to content

Instantly share code, notes, and snippets.

@NikKovIos
Created September 27, 2021 08:27
Show Gist options
  • Save NikKovIos/f113c27bbff971680618ec2e83fcf1d5 to your computer and use it in GitHub Desktop.
Save NikKovIos/f113c27bbff971680618ec2e83fcf1d5 to your computer and use it in GitHub Desktop.
Converting Optional Array to Optional Set
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