Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Scala mutable list

Scala has both a mutable and an immutable Map , but it has only an immutable List. If you want a mutable List you need a ListBuffer.

I don't understand why this is so. Any one knows?.

like image 851
Sagar Varpe Avatar asked Jul 15 '11 11:07

Sagar Varpe


2 Answers

You can choose between these:

  • scala.collection.mutable.DoubleLinkedList
  • scala.collection.mutable.LinkedList
  • scala.collection.mutable.ListBuffer
  • scala.collection.mutable.MutableList

So, yes, Scala has mutable lists :-)

like image 111
Jean-Philippe Pellet Avatar answered Sep 28 '22 17:09

Jean-Philippe Pellet


I hope that this article may be of some use to you. The diagram at the bottom of the page is particularly useful in providing the mutable and immutable classes.

http://www.scala-lang.org/docu/files/collections-api/collections_1.html

like image 21
Graham Avatar answered Sep 28 '22 17:09

Graham