'What's the difference between -- and &~ in Scala

'--' the document say: Creates a new $coll from this $coll by removing all elements of another collection.

'&~' the document say: The difference of this set and another set.

i use both of two symbol can get same result.

so is there have some difference between this two symbol? For example, there are different time complexity or memory occupation?



Solution 1:[1]

According to the Scaladoc.

-- accepts any kind of IterableOnce whereas &~ only accepts other Sets
Arguably, if you have two sets, you should prefer &~ since it is probably optimized.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Luis Miguel Mejía Suárez