Created
June 17, 2021 03:09
-
-
Save CheolhoJeon/50a46e98cf8cdbbd690b2e6fb7e869e5 to your computer and use it in GitHub Desktop.
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
package chap5.CompanionObjects | |
import atomictest.eq | |
class WithNamed { | |
companion object Named { | |
fun s() = "from Named" | |
} | |
} | |
class WithDefault { | |
companion object { | |
fun s() = "from Default" | |
} | |
} | |
fun main() { | |
WithNamed.s() eq "from Named" | |
WithNamed.Named.s() eq "from Named" | |
WithDefault.s() eq "from Default" | |
// The default name is "Companion": | |
WithDefault.Companion.s() eq "from Default" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment