4 ms·
When interacting with a Java library, I use scala.collection.JavaConversions to convert any Java structures to the equivalent Scala collection. Once I'm done op
by Cyph0n 9y ago
When interacting with a Java library, I use scala.collection.JavaConversions to convert any Java structures to the equivalent Scala collection. Once I'm done operating on the collection (map, filter, etc.), I convert it back to Java.
- nicktelford 9y agoYou should be using scala.collection.JavaConverters instead, as it makes the conversion explicit (by adding a ".asScala"/".asJava" method to collections). Implicit conversions (i.e. where a type is silently converted to another type) is dangerous and can lead to very surprising problems.
- Cyph0n 9y agoWhoops, my bad about that. I was on mobile and forgot which of the two provides `.asScala`...