I'm writing a sample application using Kotlin Coroutines. Here is a simple function I've used
fun calculateData(data: Person) {
println("Calling calculateData()...")
launch {
withContext(Dispatchers.IO) {
println("Obtained data is $data")
if(person.age > 18) {
//do some long running calculations based on 'data'
}
}
println("Some meaningful message")
}
}
The code compiles and runs OK. However, I don't get the data argument inside the Coroutine. Neither can I debug into withContext block. The message "Obtained data is $data" never gets displayed
Any clue on what prevents me from accessing that argument from within Coroutine?