scala integer weirdness
- by williamstw
Suppose you inadvertently use Integer instead of Int, as in this code:
import scala.collection.mutable.Map
val contributors = Map[String,Integer]()
val count = contributors.getOrElseUpdate("john",0)
contributors.put("john",count+1)
println(contributors)
Compiler output:
(fragment of test.scala):7: error: type mismatch;
found : Int(1)
required: String
contributors.put("john",count+1)
^
Why "required: String"?