一般而言,from mutable to immutable, 使用 to 系列方法in mutable collections, like MutableList and ListBuffer’s toList method.
from immutable to mutable, 使用构造函数: scala.collection.mutable.ListBuffer(immtableList: _).
Note that the to* methods like toList, toMap are is performed in constant time.
Map
1 | // from mutable to immutable |
List
1 | // from mutable to immutable |