I have this piece of code I inherited that works well under Scala 2.7.7 (well, replacing the import to use jcl ). But when I try to use 2.8.1 I get this error:
error: not enough arguments for constructor MapWrapper: (underlying: scala.collection.Map[String,String])collection.JavaConversions.MapWrapper[String,String]. Unspecified value parameter underlying.
Map.empty ++ new MapWrapper[String, String] {
^
I have google high and low, tried different things but I can't find how to modify the code to work on scala 2.8.1
Any pointers would be great.
Thanks
import scala.collection.JavaConversions.MapWrapper
object errorObj{
def convertToStringMap(javaMap: Hashtable[String, String]) = {
Map.empty ++ new MapWrapper[String, String]开发者_如何学Python {
def underlyinga = javaMap
}
}
}
MapWrapper
is a class in Scala 2.8 (was a trait with abstract methods in 2.7). So, you don’t need to define the abstract method underlying
anymore.
new MapWrapper[String, String](someMap)
Better yet, just import scala.collection.JavaConversions._
and let an implicit conversion turn the Java Map into a MapWrapper
for you.
精彩评论