Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created August 26, 2019 13:03
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 rail-rate/2bd212f9d7bc5f44c7892095035b2509 to your computer and use it in GitHub Desktop.
Save rail-rate/2bd212f9d7bc5f44c7892095035b2509 to your computer and use it in GitHub Desktop.
コンストラクタ7
fun main(args: Array<String>) {
val a = Test(20)
}//main
class Test(var name : String, var age : Int){
init{
println("イニシャライザブロック内です。")
println("${name}です。${age}歳です。")
}//init
constructor(age: Int) : this("名無し", age){
println("ここはセカンダリコンストラクタ内です。")
}
}//Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment