https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

Eric Ampire [MOD]

08/25/2021, 3:05 PM
Hello I'm wandering what can the advantage of having such kind of structure ?
l

louiscad

08/25/2021, 3:06 PM
Genericity, and you can still get a specific class to implement it directly.
Here, I have a
SuspendLazy
interface. I could make it implement that suspend interface: https://splitties.louiscad.com/modules/coroutines/#suspending-version-of-lazy
e

Eric Ampire [MOD]

08/25/2021, 3:38 PM
There is difference between implementing an interface such
SuspendLazy
and extending a suspend function ?
l

louiscad

08/25/2021, 3:39 PM
It's implementing, not extending a suspend function
The difference is only about the type. Here, the
SuspendLazy
interface would not be that needed actually.
Regardless, it's great for consistency that this is now possible as it was for non-suspending functions.
e

Eric Ampire [MOD]

08/25/2021, 3:44 PM
Okay I get it, but seems like it will be very useful when it came to have a class hierarchy
But when it can to have something like Command pattern it can be really interesting
2 Views