https://kotlinlang.org logo
Title
d

Doug

09/18/2020, 4:32 AM
In the following code, I’m trying to reuse a lot of the code from
ClassA
and only override a specific function in
ClassB
, is there anyway to do that, or do I need to ensure all of the methods require are created?
interface View {
  fun loadFirstPage()
  fun otherFunction()
}
open class ClassA: View {
  override fun loadFirstPage() { ... }
  override fun otherFunction() { ... }
}
class ClassB: ClassA() {
  override fun loadFirstPage() { ... }
}
when I load
ClassB
, I’m only seeing the code from
ClassA
be executed
t

Tobias Berger

09/18/2020, 7:32 AM
does this compile? I would expect an error in ClassB because
loadFirstPage
is not marked as
open
in ClassA. Otherwise this should work just fine