3 ms·
What I'm saying is, if you decided to say, use a Java HashMap in one part of your code for performance reasons. You'll have to live with that with the rest of y
by verroq 15y ago
What I'm saying is, if you decided to say, use a Java HashMap in one part of your code for performance reasons. You'll have to live with that with the rest of your code. Half of the classes in the scala library doesn't like it because it doesn't implement the required traits and as far as I can tell there is no nice way of converting between collections.
- deleted 15y ago[deleted]
- zohebv 15y agoimport scala.collection.JavaConverters._ Scala doesn't provide a built in for your specific case but import scala.collection.breakOut and you can convert mutable Java hash map to immutable scala map b = a.asScala.map(p => p)(breakOut) where b : scala.collection.immutable.HashMap[java.lang.String,Int] and a : java.util.HashMap[String,Int] Not too bad at all. Moreover, why would you want to convert a Java map to Scala if you specifically used the Java map to improve performance? How is this any worse than coding in Java itself?