I am learning Scala as a personal interest and I'm perplexed by the return value of the following:
var t : Long = 1
def product(s:String):Long = {
if(s.length > 1) t *= product(s.tail)
else t *= s.toLong
}
This is a recursive function,but the compiler tall me two errors that:
<console>:13: error: type mismatch;
found : Unit
required: Long
if(s.length > 1) t *= product(s.tail)
^
<console>:14: error: type mismatch;
found : Unit
required: Long
else t *= s.toLong
^
and in scala-doc ,i can't find the def *= in Long.