Junior — Senior
Analysis of the compilation error in a Kotlin class
livecode
Task condition
It is necessary to find out why the code below does not compile.
class Student(var name: String) {
init {
println("Student has got a name as $name")
}
constructor(section: String, var studentId: Int) : this(section) {
}
}
Note that the constructor uses the var modifier before the parameter, and there is an attempt to call the primary constructor with the same parameter section, which causes a conflict.