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

Slackbot

02/05/2020, 10:25 AM
This message was deleted.
o

octylFractal

02/05/2020, 10:35 AM
shouldn't this be in #general ? not sure what's coroutine-related about this
k

Kristoffer Andersen

02/05/2020, 10:35 AM
You can put bounds on the parameters on the extension function:
Copy code
class A<T>(val contents: T)

fun <T : Number> A<T>.foo(): Int = contents.toInt() + 4

val x = A(4).foo()
val y = A("Test").foo()
k

Kroppeb

02/05/2020, 10:35 AM
Oof, I though I posted this in general, Is there a way to move a msg?
@Kristoffer Andersen That does only allow you to specify a type parameter for the receiver function, not for the context.
4 Views