0
我想返回一個名爲Entry的案例類,所以我不能更改函數的簽名。當我充滿了我的情況下類,並試圖返回它,我得到以下錯誤:scala返回案例類別不匹配
<console>:13: error: type mismatch;
found : Entry(in method apply)
required: <empty>.Entry
我不知道爲什麼功能要求該類型
def apply(line: String) : Entry = {
case class Entry(account:String, password:String, UID:Int, GID:Int,
GECOS:String, directory:String, shell:String)
val fields = line.split(":")
val x = Entry(fields(0), fields(1), fields(2).toInt, fields(3).toInt,
fields(4), fields(5), fields(6))
x
}
謝謝,這是問題所在。 – Sugihara