I think a better practice would be to have an inner function (traditionally called loop), that way your caller doesn't need to know the dirty details of you using recursion. Also.... you probably want to add @tailrec, to make sure your function can be optimized by the compiler.
I think a better practice would be to have an inner function (traditionally called
loop
), that way your caller doesn't need to know the dirty details of you using recursion. Also.... you probably want to add @tailrec, to make sure your function can be optimized by the compiler.Plus an implicit int is a really bad idea!
I am not sure the function is tail recursive...