Created
September 13, 2022 07:56
-
-
Save omkar-tenkale/92763e3cf3fc9f5215323f0e65abf39a to your computer and use it in GitHub Desktop.
Inheritance for multi module project in kotlin, android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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