Does Scala support tail recursion optimization?
Scala does tail recursion optimisation at compile-time, as other posters have said. That is, a tail recursive function is transformed into a loop by the compiler (a method invoke is transformed into a jump), as can be seen from the stack trace when running a tail recursive function. Try the following snippet: def boom(n: Int): … Read more