Sublime Forum

Tail Recursive in Scala

#1

Hello Everyone, I am new in this community. Can anyone tell me what the process of tail recursive in scala? I am confused to understand it . I also want to know the specific work of this process. I am preparing some scala interview questions for my upcoming interview. Can anyone suggest me some tips for scala profile?

0 Likes

#2

Without a doubt, you should use tail recursion because the performance benefits are just that large.

0 Likes

#3

Yes, I also support you need to use tail recursion.

A tail-recursive function is just a function whose very last action is a call to itself. When you write your recursive function in this way, the Scala compiler can optimize the resulting JVM bytecode so that the function requires only one stack frame — as opposed to one stack frame for each level of recursion!

0 Likes