Last active
January 27, 2018 07:30
-
-
Save abdurahmanadilovic/82f15c844bf5641b7a5163f24fdf672a to your computer and use it in GitHub Desktop.
Kotlin secondary constructor
This file contains hidden or 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
class SecondaryConstructor(){ | |
val blog = "www.codingstoic.com" | |
val city = "Sarajevo" | |
constructor(aValue: Int) : this(){ | |
println("a second constructor") | |
} | |
init{ | |
println("inside the first init block") | |
println("blog is $blog and city is $city") | |
} | |
init{ | |
println("inside the second init") | |
} | |
} | |
fun main(args: Array<String>) { | |
SecondaryConstructor(1) | |
} | |
// --- output --- | |
// inside the first init block | |
// blog is www.codingstoic.com and city is Sarajevo | |
// inside the second init | |
// a second constructor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment