So, I'm fairly new to coroutines in kotlin and I don't understand what's going on here. I do have a suspended function called from another one.
What's the right syntax here?
suspend fun doSomething(str: Optional<String>) {
// Error: Suspension functions can be called only within coroutine body
str.map { doSomethingElse() }
}
suspend fun doSomethingElse() { }
whereas, this is fine
suspend fun doSomething(str: Optional<String>) {
if (str.isPresent) {
doSomethingElse()
}
}
suspend fun doSomethingElse() {}