209ba89a49
to be the only constructor which includes `init` block when there is no primary constructors in the class
72 lines
817 B
Kotlin
Vendored
72 lines
817 B
Kotlin
Vendored
class A(val str: String) {
|
|
|
|
constructor(i: Int) : this(i.toString())
|
|
|
|
}
|
|
|
|
class AWithInit(val str: String) {
|
|
|
|
init {
|
|
println()
|
|
}
|
|
|
|
constructor(i: Int) : this(i.toString())
|
|
|
|
}
|
|
|
|
class AWith2Init(val str: String) {
|
|
|
|
init {
|
|
println(1)
|
|
}
|
|
|
|
init {
|
|
println(2)
|
|
}
|
|
|
|
constructor(i: Int) : this(i.toString())
|
|
|
|
}
|
|
|
|
class AOnlyInit {
|
|
|
|
init {
|
|
println(1)
|
|
}
|
|
|
|
init {
|
|
println(2)
|
|
}
|
|
}
|
|
|
|
class AWithSecondary {
|
|
|
|
lateinit var a: String
|
|
|
|
constructor(i: Int) {
|
|
a = i.toString()
|
|
}
|
|
|
|
constructor(s: String) {
|
|
a = s
|
|
}
|
|
|
|
}
|
|
|
|
class AWithSecondaryInit {
|
|
|
|
lateinit var a: String
|
|
|
|
init {
|
|
println()
|
|
}
|
|
|
|
constructor(i: Int) {
|
|
a = i.toString()
|
|
}
|
|
|
|
constructor(s: String) {
|
|
a = s
|
|
}
|
|
|
|
} |