Search code examples
scalascala-java-interopscala-2.11scala-2.12scala-2.13

Version agnostic way to convert from Java to Scala collections and back


Almost each Scala version changes the way collection conversion happens in a non-backward compatible way. Is there a better solution that is version agnostic and does not depend on Scala distribution?

I don't mind using some 3rd party libraries.


Solution

  • Just use the scala-collections-compat library and then you can use import scala.jdk.CollectionConverters._ on Scala 2.11, 2.12 & 2.13.