What am I doing wrong? Where does String
come from?
Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL
scala> List(1).fold(Map()) { (m, x) => m + (x -> 1) }
<console>:9: error: type mismatch;
found : (Any, Int)
required: String
List(1).fold(Map()) { (m, x) => m + (x -> 1) }
^
scala> List(1).foldLeft(Map()) { (m, x) => m + (x -> 1) }
<console>:9: error: type mismatch;
found : (Int, Int)
required: (Nothing, Nothing)
List(1).foldLeft(Map()) { (m, x) => m + (x -> 1) }
^