You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The primary constructor is part of the class header: it goes after the class name (and optional type parameters).
But in is useless - it can be omitted.
Bad example:
// simple case that does not need a primary constructorclassTest() {
var a:Int=0var b:Int=0
}
// empty primary constructor is not needed here also// it can be replaced with a primary contructor with one argument or removedclassTest() {
var a ="Property"init {
println("some init")
}
constructor(a:String):this() {
this.a = a
}
}
Good example:
// the good example here is a data class, but this example shows that you should get rid of braces for primary constructorclassTest {
var a:Int=0var b:Int=0
}
The text was updated successfully, but these errors were encountered:
The primary constructor is part of the class header: it goes after the class name (and optional type parameters).
But in is useless - it can be omitted.
Bad example:
Good example:
The text was updated successfully, but these errors were encountered: