Scala type conversion error, need help!
- by Mansoor Ashraf
Hello
I am getting a weird error when trying to use a Java map in Scala. This is the snippet of code
val value:Double = map.get(name)
if (value eq null) map.put(name, time) else map.put(name, value + time)
the map is defined as
val map=new ConcurrentHashMap[String,Double]
and this is the error I am getting
error: type mismatch;
found : Double
required: ?{val eq: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method double2Double in object Predef of type (Double)java.lang.Double
and method doubleWrapper in object Predef of type (Double)scala.runtime.RichDouble
are possible conversion functions from Double to ?{val eq: ?}
if (value eq null) map.put(name, time)
I am new to Scala so I am having a hard time parsing the stacktrace. Any help would be appreciated