scala - What's wrong with the expression `new ListBuffer.empty[Int]` -
i found works well:
val buf = scala.collection.mutable.listbuffer.empty[int]
but, doesn't work:
import scala.collection.mutable.listbuffer val buf = new listbuffer.empty[int]
the compiler complains:
error:(2, 32) type empty not member of object scala.collection.mutable.listbuffer lazy val buf = new listbuffer.empty[int] ^
does have ideas this?
listbuffer.empty
isn't constructor, it's function returns empty listbuffer.
there's no need new
keyword.
Comments
Post a Comment