Skip to content

Instantly share code, notes, and snippets.

@channyeintun
Last active May 7, 2021 09:58
Show Gist options
  • Select an option

  • Save channyeintun/aa75fac723d7b08b4fcae0b542eda0cf to your computer and use it in GitHub Desktop.

Select an option

Save channyeintun/aa75fac723d7b08b4fcae0b542eda0cf to your computer and use it in GitHub Desktop.
package main
class Constructors(val color:String){
init {
println("Init Color=$color")
}
//val or var is not allowed on secondary constructors
//You cannot declare a return type for a secondary constructor
constructor(color:String,value:Int):this(color){
println("Color=$color,Value=$value")
}
fun showColor():Unit{
println("Color is $color")
}
}
fun main(){
val test:Color=Color("Red",12)
test.showColor()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment