Skip to content

Instantly share code, notes, and snippets.

@omkar-tenkale
Created September 13, 2022 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omkar-tenkale/92763e3cf3fc9f5215323f0e65abf39a to your computer and use it in GitHub Desktop.
Save omkar-tenkale/92763e3cf3fc9f5215323f0e65abf39a to your computer and use it in GitHub Desktop.
Inheritance for multi module project in kotlin, android
import kotlinx.coroutines.*
fun main() {
BaseAPIImpl().endpoint1()
ModuleAPIImpl().endpoint1()
ModuleAPIImpl().endpoint2()
(ModuleAPIImpl() as ModuleAPI).endpoint1()
(ModuleAPIImpl() as ModuleAPI).endpoint2()
}
interface BaseAPI{
fun endpoint1()
}
open class BaseAPIImpl: BaseAPI{
override fun endpoint1(){
println("BaseAPIImpl endpoint1")
}
}
interface ModuleAPI :BaseAPI {
fun endpoint2()
}
class ModuleAPIImpl : BaseAPIImpl(), ModuleAPI{
override fun endpoint2(){
println("ModuleAPIImpl endpoint2")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment