Yeah, I'd rewrite this function to: ```suspend fu...
# coroutines
k
Yeah, I'd rewrite this function to:
Copy code
suspend fun logSlow(logAfter: Duration = 10.seconds, block: suspend () -> T): T = coroutineScope {
  val logJob = launch {
    delay(logAfter)
    log.error(...)
  }
  return try {
    block()
  } finally {
    logJob.cancel()
  }
}
☝🏻 1
🧵 4
☝️ 2
☝🏽 1