Is there standard Kotlin analog of Guava `Sets.dif...
# announcements
t
Is there standard Kotlin analog of Guava
Sets.difference
? In Kotlin it will be:
Copy code
fun Set<T>.difference(other: Set<T>): Set<T>
{
  return subtrack(other) + other.subtrack(this)
}
s
looking at the docs for that
Sets.difference()
method, it doesn’t seem like it works like your code snippet:
>>
The returned set contains all elements that are contained by set1 and not contained by set2. set2 may also contain elements not present in set1; these are simply ignored.
Set.subtract()
seems to already fulfill this requirement
t
@Shawn thank you
👍 1
s
the difference extension method you wrote looks more like a
symmetricDifference
method, which I don’t believe Kotlin provides
Guava does have a method that takes care of that, however