https://kotlinlang.org logo
r

raniejade

11/06/2017, 11:23 AM
Hi! Why is something like this not possible?
Copy code
class F {
    suspend fun CoroutineScope.process() {

    }
}

fun main(args: Array<String>) {
    launch {
        val f = F()
        // unresolved reference
        f.process()
    }
}
m

marstran

11/06/2017, 11:28 AM
You need to call the function on a
CoroutineScope
.
Use this syntax:
Copy code
with(f) {
  myCoroutineScope.process()
}
r

raniejade

11/06/2017, 11:29 AM
ahh, shit yes. :))
thank you @marstran
m

marstran

11/06/2017, 11:29 AM
No problem
r

raniejade

11/06/2017, 11:30 AM
What a dumb mistake 🙂
2 Views