Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created June 17, 2021 06:54
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 CheolhoJeon/f0eff9beb20ece559617ab08792e10f8 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/f0eff9beb20ece559617ab08792e10f8 to your computer and use it in GitHub Desktop.
package chap5.CompanionObjects
import atomictest.eq
interface Extended: ZI {
fun u(): String
}
class Extend : ZI by Companion, Extended {
companion object: ZI {
override fun f() = "Extend.f()"
override fun g() = "Extend.g()"
}
override fun u() = "${f()} ${g()}"
}
private fun test(e: Extended): String {
e.f()
e.g()
return e.u()
}
fun main() {
test(Extend()) eq "Extend.f() Extend.g()"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment