scala.io.Sourceはたぶんimportしたらいいとおもう。下の方は、2.11から使えるようだ。
scala.io.Source.fromInputStream(is).getLines().mkString("\n")
scala.io.Source.fromInputStream(is).mkString
scala.io.Sourceはたぶんimportしたらいいとおもう。下の方は、2.11から使えるようだ。
scala.io.Source.fromInputStream(is).getLines().mkString("\n")
scala.io.Source.fromInputStream(is).mkString
くらいでしょうか。とりあえずソースコード読みます。
本当に薄らぼんやりとした使い方。mutableなListBufferを使うと、+=でどんどん要素を増やせる。empty[T]でListBufferを初期化。emptyは使われているっぽい。
scala> case class A(a: Int, b: String) defined class A scala> scala> val a = scala.collection.mutable.ListBuffer.empty[A] a: scala.collection.mutable.ListBuffer[A] = ListBuffer() scala> a += A(1, "hoge") res0: a.type = ListBuffer(A(1,hoge)) scala> a res1: scala.collection.mutable.ListBuffer[A] = ListBuffer(A(1,hoge))