Scala 2.12まで
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 12.0.1). Type in expressions for evaluation. Or try :help. scala> val seq1: scala.Seq[Int] = scala.collection.immutable.Seq(1, 2) seq1: Seq[Int] = List(1, 2) scala> val seq2: scala.Seq[Int] = scala.collection.mutable.Seq(1, 2) seq2: Seq[Int] = ArrayBuffer(1, 2)
Scala 2.13から
Welcome to Scala 2.13.0-RC3 (OpenJDK 64-Bit Server VM, Java 12.0.1). Type in expressions for evaluation. Or try :help. scala> val seq1: scala.Seq[Int] = scala.collection.immutable.Seq(1, 2) seq1: Seq[Int] = List(1, 2) scala> val seq2: scala.Seq[Int] = scala.collection.mutable.Seq(1, 2) ^ error: type mismatch; found : Seq[Int] (in scala.collection.mutable) required: Seq[Int] (in scala.collection.immutable)
もうmutable.Seqは代入できない…っていうか今までできたんだ…知らなかった…