Consider a scala code:
def myRecursiveFunction(id:string):Unit= {
myAsyncDao.search(id).foreach {response=>
myRecursiveFunction(response.id)
}
}
//myAsyncDao.search returns a Future
//response have id field for further computations
If I put @tailrec
on top op function, compile complains Recusive call not in tail position
.
Can it be optimizated as tail recursion?
How about
Update: