I need help using an if statement that should only be run if the test is false in a for-comprehension dealing with futures. I am new to scala and using this blog post as my guide.
The code is
for {
emptyResults: Boolean = areResultsEmpty(content)
resp <- getResp(content) if !emptyResults
} yield resp
If emptyResults
is true then the getResp()
throws an error, but in the above, getResp()
gets run even when emptyResults
is true. How do I make sure that the getResp()
only gets run if emptyResults
is false?
I have also tried writing the if statement like below but that throws an error error: value map is not a member of Any
acmResp <- if (!emptyResults) {
getResp(content)
}
I have looked over other solutions here including this and this and this but they haven't helped with this issue.