0
我嘗試用於理解,以製作一個字符串映射到MyData案例類。爲理解產量地圖
這是我曾嘗試:
case class MyDataProperty(name: String, value: String)
case class MyData(props: List[MyDataProperty])
def makeMyData(configs: List[Config]): Map[String, MyData] = {
for {
// loop through all configurations
conf <- configs
// Retrieve each config's list of properties and make a list of MyDataProperty object from it
props <- for(prop <- conf.properties) yield (MyDataProperty(prop.name, prop.value))
} yield (conf.name -> MyData(props)) toMap
}
此代碼給我多編譯錯誤。建立這種理解和產生地圖的巢穴的正確方法是什麼?
什麼是你所得到的編譯錯誤? – tuxdna