I am a beginner in Kotlin. I have a kt file that no class function name "test1" which is the same as the class name.
android studio compiler display error message.
Kotlin: Conflicting overloads: public constructor test1() defined in com.demo.test1, public fun test1(): Unit defined in com.demo.
Why can’t class name and function name be the same?
they are essentially different in nature,
or how to correct them?
test1.kt
package com.demo
class test1() {
init {
println("First initializer ");
}
}
main.kt
package com.demo
fun test1() {
var s1: String? = "10.25"
println(s1)
}
fun main(argus: Array<String>) {
test1();
}
question from:
https://stackoverflow.com/questions/65887884/why-compiler-kotlin-with-error-message-conflicting-overloads-problem 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…