Suppose I wanted to add some convenience operators for set union, intersection, and subtraction.
I can do it for Set<Character> or any specific type of element, e.g.
func + (left: Set<Character>, right: Set<Character>) -> Set<Character> {
return left.union(right)
}
But how could I define that so that it will work generically?
So far everything that I've tried has failed. I'm guessing that the solution will involve extending Set, but my grasp of generics is tenuous at this point, so I'd appreaciate help.
None of this is actually vital to anything I'm doing. These definitions are for convenience, but I decided to take the opportunity to play with defining operators.