aeruhxi
03/04/2020, 9:15 AM/**
* You can edit, run, and share this code.
* <http://play.kotlinlang.org|play.kotlinlang.org>
*/
import kotlinx.coroutines.*
fun main() {
println("Hello, world!!!")
CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
(1..1000).forEach {
suspend {
delay(2000)
print("Testing...")
}
}
}
}
What kind of block is suspend {}
?elizarov
03/04/2020, 9:27 AM{}
block, but the code can suspend inside. Assign to a variable to use it, like this: val block = suspend { … }
.aeruhxi
03/08/2020, 5:49 AM