下一個代碼斯卡拉 - 修真類型推斷
def f(chars: List[Char]): List[List[Char]] = chars match {
case Nil => List(Nil)
case x :: xs => for {
v <- f(xs)
} yield List(x) :: v
}
提供錯誤消息
- type mismatch; found : List[List[Any]] required: List[List[Char]]
請幫助我理解爲什麼「的」選擇了這裏最普遍的,而不是任何的字符?我應該閱讀什麼語言規範的主題?謝謝。