Why is there a lack of consistency between Sets and Lists in Scala Collections API?
For example, there is immutable Set, but also a mutable one. If I want to use the latter, I can simply do this:
val set = Set[A]()
set += new A
However, there is no mutable List, per se. If I want to write a similar code snippet using Lists, which data structure to use? LinkedList sounds as a good candidate, because it is mutable, but has no += method defined. ListBuffer seems to satisfy the requirements, but it is not a list.
After reading 2.8 Collections docs I come to the conclusion MutableList is probably the best fit.
I still somehow wish there was scala.collection.mutable.List.
The reason for this is that Java has co-opted the functional
Listtype to mean something that it is not (i.e.java.util.Listis not a list).It probably makes no sense for a functional programming language to have a mutable
Listas such a type is an oxymoron. HenceListBufferorArrayBuffer. Or just useIndexedSeq, of which there are mutable and immutable implementations