Skip to content

Instantly share code, notes, and snippets.

@renaudcerrato
Last active February 19, 2019 09:05
Show Gist options
  • Save renaudcerrato/f16c1d3770472da81299a57517b3706c to your computer and use it in GitHub Desktop.
Save renaudcerrato/f16c1d3770472da81299a57517b3706c to your computer and use it in GitHub Desktop.
Kotlin Secondary Constructors
class Person(val name: String) {
// secondary constructors must delegate to the primary constructor
constructor(name: String, parent: Person) : this(name) {
parent.children.add(this)
}
init {
println("I'm called before the secondary constructor")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment