I have the following recursive call written in 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
}
The commented line is throwing type mismatch error and saying Found: Anyval Required:Int.
Can anyone please tell what is the problem here?
isInstanceOfin Scala, we have better tools like pattern matching for that.