How can I define a custom equality operation that will be used by immutable Set comparison methods

后端 未结 4 650
南笙
南笙 2020-12-05 09:46

I have an immutable Set of a class, Set[MyClass], and I want to use the Set methods intersect and diff, but I want them to test for equality using my custom equals method, r

4条回答
  •  抹茶落季
    2020-12-05 09:57

    This answer shows a custom mutable Set with user-defined Equality. It could be made immutable by replacing the internal store with a Vector and returning a modified copy of itself upon each operation

提交回复
热议问题