Last active
May 16, 2021 09:49
-
-
Save swiftyfinch/7ebb2336a4ee3f81b722a5889c7be9d0 to your computer and use it in GitHub Desktop.
Inserts an collection to Set (It's not the same as union)
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 Set { | |
/// Inserts other collection to current. It works like the `insert` method, but not like the `union`. | |
func inserts<S: Sequence>(_ other: S) -> Self where S.Element == Element { | |
var new = self | |
other.forEach { new.insert($0) } | |
return new | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment