I am trying to convert each list integer to its absolute value using the following Scala statement, I am getting an invalid type match error:
def f(arr:List[Int]):List[Int] = arr.map((x: Int) => if(x<0) -1*x)
Solution.scala:2: error: type mismatch;
found : List[AnyVal]
required: List[Int]
def f(arr:List[Int]):List[Int] = arr.map((x: Int) => if(x<0) -1*x)
^