Scala type conversion error, need help!
Posted
by Mansoor Ashraf
on Stack Overflow
See other posts from Stack Overflow
or by Mansoor Ashraf
Published on 2010-06-08T15:01:40Z
Indexed on
2010/06/08
19:22 UTC
Read the original article
Hit count: 446
scala
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
© Stack Overflow or respective owner