Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created June 17, 2021 07:42
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/c05fd6b275a80736e4c924fccb6f4988 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/c05fd6b275a80736e4c924fccb6f4988 to your computer and use it in GitHub Desktop.
package chap5.CompanionObjects
import atomictest.trace
class CompanionInit {
companion object {
init {
trace("Companion Constructor")
}
}
}
fun main() {
trace("Before")
CompanionInit()
trace("After 1")
CompanionInit()
trace("After 2")
CompanionInit()
trace("After 3")
trace eq """
Before
Companion Constructor
After 1
After 2
After 3
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment