I have used and read about @tailrec annotation to have a tail recursive method. I have gone through many links that explains it. For example it only works when for
@tailrec