【发布时间】:2016-07-12 19:52:26
【问题描述】:
我刚刚习惯了 Scala,而且我已经
case class Person(name: String, birthPlace: String, hairColor: String)
我知道应该有一种将 List[Person] 转换为的好方法
Map[Name, Map[Birthplace, Person]]
但是,我不知道该怎么做。
我们将不胜感激。
【问题讨论】:
-
只是一个一般性问题:为什么不存储 2 个单独的地图(假设多个人可以拥有同一个出生地)? Map[Name,List[Person]] 和 Map[Birthplace,List[Person]] 然后 resultPersonListA.intersect(resultPersonListB) ? imo 的优点是您可以直接访问这两个地图?
标签: scala dictionary collections