我有以下用 Scala 编写的递归调用:
def calculateFingerPrint(t: Tree):Int =
{
if(t.isInstanceOf[Leaf])
calculateIDS(t).hashCode()
else if(t.isInstanceOf[OtherNode])
//error --> calculateIDS(t).concat(calculateFingerPrint(t.children.head).toString()).hashCode
}
def calculateIDS(t: Tree):String= {
//returns some string
}
注释行抛出类型不匹配错误并说Found: Anyval Required:Int
.
谁能告诉这里有什么问题?