Nowadays I am learning Kotlin and I have a question. I'm writing the code below and I get the error "The integer literal does not conform to the expected type String".
fun main() {
fun <Any> MutableList<Any>.yaz(name : Any) : Any = name;
var mutableList : MutableList<String> = ArrayList<String>()
println(mutableList.yaz(1))
println(mutableList.yaz("Selam"))
}
Where am I making a mistake? I would be very happy if you can help. Thanks!
It works when I write as follows, but I didn't understand why.
fun <Any> MutableList<out Any>.yaz(name : Any) : Any = name;