尝试在Scala中使用Java映射时,我遇到了一个奇怪的错误.这是代码片段
val value:Double = map.get(name)
if (value eq null) map.put(name, time) else map.put(name, value + time)
Run Code Online (Sandbox Code Playgroud)
地图定义为
val map=new ConcurrentHashMap[String,Double]
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误
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)
Run Code Online (Sandbox Code Playgroud)
我是Scala的新手,所以我很难解析堆栈跟踪.任何帮助,将不胜感激
scala ×1