Is it possible to extend an existing Kotlin class ...
# multiplatform
m
Is it possible to extend an existing Kotlin class to conform to a interface?
Copy code
data class MediaItem(
    override val title: String,
    override val artist: String?
)
Copy code
interface MediaItemProtocol {
    val title: String
    val artist: String?
Copy code
extend AstroMediaItem: MediaItemProtocol {

}
this sort of thing is possible in swift, such as:
Copy code
extension MediaItem: MediaItemProtocol { 

}
e
no, extension interfaces are not possible
m
so with a modular approach where by a model definition is in one package and protocol in another, that means having a third definition to bind the two?
Copy code
class MediaItemWrapper(private val item: MediaItem) : MediaItemProtocol {
    override val title: String get() = item.title
    override val artist: String? get() = item.artist
}