简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM