Below is the map1.scala file in IntelijIDEA
It seems i hit the wall once again. I have no idea why the following is error:
abstract class List[T] {
def map[U](f: T => U): List[U] = {
this match {
case Nil => this
case x :: xs => ???
}
}
}
case Nil: pattern type is incompatible with expected type: found Nil.type expected List[T] this: expression of type List[T] doesn't conform to expected type List[U] x :: xs Pattern type incompatible found ::B required List[T]..
I tried everything... But still have this problem. However knows please respond.
Nil
is a type ofList
from standard library and you compare it with your own classList.
Rename your list toMyList
,MyNil
and do not confuse yourself. – Nikita