Ifvwm
06/28/2020, 2:12 PMinterface IS<T> {fun <T>T.fmap():T}
sealed class IIS<T>: IS<T>
data class IntIS<Int>(val x:Int): IIS<Int>(){
fun Int.fmap(){
return x+1
}
}
deactivateduser
06/28/2020, 2:31 PMIfvwm
06/28/2020, 2:35 PMdeactivateduser
06/28/2020, 2:43 PMKroppeb
06/28/2020, 2:47 PMIfvwm
06/28/2020, 3:03 PMreturn this
can't be return x+1
in your code? there's (val x: Int) in the constractordeactivateduser
06/28/2020, 3:25 PMthis
with x+1
and the compiler will tell you why that one cannot be done... 😉.. basically, the returned type is different...Ifvwm
06/28/2020, 3:28 PMreturn x+1
won't be Int?Kroppeb
06/28/2020, 4:57 PMInt
type