dsg*_*dsg 50 scala map variadic-functions
Map
在scala中创建时,我打电话给我Map(entities.map{e => e.id -> e})
,然后我得到:
found : scala.collection.mutable.IndexedSeq[(Int, Entity)]
required: (Int, Entity)
Run Code Online (Sandbox Code Playgroud)
这是因为签名Map.apply
是:def apply[A, B](elems: (A, B)*): CC[A, B]
,这需要一个varargs样式参数.
有没有办法转换,IndexedSeq
以便可以通过Map.apply
?