The google codelab Android Room with a View - Kotlin has the following snippet:
class WordViewModel(application: Application) : AndroidViewModel(application) {
// ...
private val coroutineContext: CoroutineContext
get() = parentJob + Dispatchers.Main
private val scope = CoroutineScope(coroutineContext)
// ...
}
And from what I understand from this answer, the custom getter is evaluated everytime, whereas the assignment is evaluated at the time of constructing only. So in effect, scope
would take a value that wouldn't change later, so what use is the custom getter for coroutineContext
?