I am new to scala and I came across this code:
def map_2[A, B](l: List[A])(f: A => B): List[B] = {
val buf = new collection.mutable.ListBuffer[B]
@tailrec
def go(l: List[A]): Unit = l match {
case Nil => ()
case Cons(h, t) => buf += f(h); go(t)
}
go(l)
List(buf.toList *)
} // converting from the standard Scala list to the list we've defined here
I understand what it does (it maps a list), but I am getting a compilation error at List(buf.toList *)
saying that Cannot resolve symbol *
.
I tried the suggested fixes by intellij idea like import scala.language.postfixOps
(even though I don't know whats this), but no luck.
What is this error and how to solve it?