In Scala how do I remove duplicates from a list?

Have a look at the ScalaDoc for Seq,

scala> dirty.distinct
res0: List[java.lang.String] = List(a, b, c)

Update. Others have suggested using Set rather than List. That’s fine, but be aware that by default, the Set interface doesn’t preserve element order. You may want to use a Set implementation that explicitly does preserve order, such as collection.mutable.LinkedHashSet.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)