【发布时间】:2016-08-20 19:39:36
【问题描述】:
我正在尝试调用 Map.canBuildFrom(("dataLine", dataLine));其中data line是HashMap,我要传hashMap,怎么做?
val myCustomFeeder = new Feeder[String] {
override def hasNext = true
override def next: Map[String, String] = {
var dataLine: java.util.HashMap[String, String] = new RandomDataGenerator().getMessageMap(); // this returns a java.util.HashMap
Map.canBuildFrom(("dataLine", dataLine)); // does not compile.
}
}
我得到的错误是:
Error:(91, 11) overloaded method value apply with alternatives:
()scala.collection.mutable.Builder[(A, B),scala.collection.immutable.Map[A,B]] <and>
(from: Map.Coll)scala.collection.mutable.Builder[(A, B),scala.collection.immutable.Map[A,B]]
cannot be applied to ((String, java.util.HashMap[String,String]))
Map.canBuildFrom(("dataLine", dataLine));
^
【问题讨论】:
-
“不编译”:你得到了什么错误?
-
我更新了错误,详情
-
你为什么要这么做?如果您想将 java 地图转换为 scsala 地图,请使用
scala.collection.JavaConverters
标签: java scala dictionary hashmap gatling