In swift, we can confirm to any protocol / interfa...
# getting-started
r
In swift, we can confirm to any protocol / interface using extensions. Can we add interface conformance to certain class using extension in Kotlin?
g
No, it’s not possible and probably will never be supported, because it wouldn’t work on JVM without some huge hacks and will anyway break compatibility with Java
r
ok, thanks.
s
sounds like traits in Rust!? I enjoy figuring out the difference between those and the interfaces I'm used to Java/Kotlin (apart from the obvious fact that interface extension can only happen while the extending class itselft is written. E.g. implementing traits not for a specific struct but for other traits.) But yeah, in regards to the original question: that doesn't work in Kotlin.
👍 1