【发布时间】:2011-03-31 04:45:48
【问题描述】:
在 scala 中创建Map 时,我调用Map(entities.map{e => e.id -> e}),我得到:
found : scala.collection.mutable.IndexedSeq[(Int, Entity)]
required: (Int, Entity)
这是因为Map.apply 的签名是:def apply[A, B](elems: (A, B)*): CC[A, B],
这需要一个可变参数样式参数。
有没有办法将IndexedSeq 转换为可以通过Map.apply 接受?
【问题讨论】:
标签: scala map variadic-functions