[swift-users] Subtract a set of a subclass?

Nick Brook nrbrook at gmail.com
Wed Aug 31 19:31:37 CDT 2016


I have a set, Set<A> and a subset of that, Set<B>, where B: A. I want to subtract Set<B> from Set<A>, but the subtract function signature specifies that the set elements must be the same type (S.Generator.Element == Element). I guess this is because Element is not required to be a class, simply hashable, therefore inheritance is not guaranteed? Is there any way this could be implemented in Set, in an extension, or what would be the most efficient way to perform that operation?

Thanks

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160901/ae410e78/attachment.html>


More information about the swift-users mailing list