Implicit conversion between java and scala collections using JavaConversions

后端 未结 2 1054
感情败类
感情败类 2021-01-29 00:02

I merged a scala Set of scala Maps using a generic function

def mergeMaps[A, B](ms: Set[Map[A, B]])(f: (B, B) => B): Map[A, B] =
(Ma         


        
2条回答
  •  一个人的身影
    2021-01-29 00:28

    Would a JavaConverter do what you want?

    scala> import scala.collection.JavaConverters._
    import scala.collection.JavaConverters._
    
    scala> val x = (new java.util.HashMap[Int,Int]).asScala
    x: scala.collection.mutable.Map[Int,Int] = Map()
    

提交回复
热议问题