When I google Kotlin / unused arguments, Gemini AI says, confidently, “In Kotlin, you can mark an unused argument in a method or function using the underscore (
_
) character.” and even gives an example:
Copy code
fun greetUser(name: String, _: Int) {
println("Hello, $name!")
}
… but that is incorrect, right?
v
Vampire
02/02/2025, 11:59 PM
Of course this is incorrect, what do you expect from an AI? 🙂
They are super good in giving answers that look correct, but super bad in giving answers that are correct.
You can use the underscore if you for example give some lambda somewhere and do not need all parameters you have to specify.