Interface in Kotlin? I’m having a hard time wrapping my mind around how that would be useful.
j
jw
08/14/2023, 8:29 PM
having a supertype that only exists on a particular platform
jw
08/14/2023, 8:29 PM
having functions that only exist on a particular platform
jw
08/14/2023, 8:30 PM
using a typealias to a platform-specific type on a particular platform
k
Kapil Yadav
08/15/2023, 3:18 AM
In simple common can't have everything as platform dependency is huge. So we have expect actual.
We expect something from common code like showToast and actual implements to every platform we're using. We need to code the actual function.
j
Jacob Rhoda
08/15/2023, 5:18 AM
Yes but I am asking specifically about interfaces. Why would you want the contract of a class to be different in different platforms?
h
hfhbd
08/15/2023, 8:44 AM
You can add more methods on a particular platform
hfhbd
08/15/2023, 8:49 AM
But as a user this can be strange sometimes. For example ktor uses this pattern including a common helper method which creates the type, so you need to pass platform specific parameters which are unused on other platforms. So you should be careful about your public api.