I can collect the results at the inner-most for
body into a List[Output]
and return them. But I want to use yield
. How can this method be converted into using for-yield
pattern:
def useForComprehension(input : Input): List[Output] = {
for (o <- splitInputIntoPieces(input)) {
for (restResults <- useForComprehension(subtract(input, o)) ) {
for (w <- f3(o)) {
yield w::restResults // !!!!! Error
}
}
}
}