I think there is @tailrec annotation to ensure the compiler will optimize a tail recursive function. Do you just put it in front of the declaration? Does it also work if Scala is used in scripting mode (for instance using :load <file> under REPL)?
I think there is @tailrec annotation to ensure the compiler will optimize a tail
Share
From the "Tail calls, @tailrec and trampolines" blog post:
Example:
And it works from the REPL (example from the Scala REPL tips and tricks):