Scala compiler says unreachable code, why?
Posted
by taotree
on Stack Overflow
See other posts from Stack Overflow
or by taotree
Published on 2010-04-13T18:41:32Z
Indexed on
2010/04/13
18:43 UTC
Read the original article
Hit count: 385
I'm new to Scala... Here's the code:
def ack2(m: BigInt, n: BigInt): BigInt = {
val z = BigInt(0)
(m,n) match {
case (z,_) => n+1
case (_,z) => ack2(m-1,1) // Compiler says unreachable code on the paren of ack2(
case _ => ack2(m-1, ack2(m, n-1)) // Compiler says unreachable code on the paren of ack2(
}
}
I'm trying to understand that... why is it giving that error?
© Stack Overflow or respective owner