https://kotlinlang.org logo
#announcements
Title
# announcements
n

nkiesel

03/01/2017, 10:57 PM
1.1 allows
_
for unused parameters of lambda expressions (and it seems also for unused values in a destructive assignments). Why does that not also work for unused parameters of methods? e.g.
fun main(_: Array<String>) {
l

lovis

03/02/2017, 8:47 AM
nkiesel: because that looks ugly 😉
n

nkiesel

03/02/2017, 8:51 AM
hey, beauty is in the eye of the beholder! but really, the intent was the same as in the other usages of `_`: signal the body that we do not want to use this value. But I guess the "what about named parameters?" point means this idea is officially dead.
o

okkero

03/02/2017, 8:53 AM
I tested giving different names to parameters when overriding a method, and indeed IDEA gives a warning. But then I tested calling the method, both through a superclass reference and through a subclass reference. And while I did have to change the name of the named argument when calling each of them, I really didn't see it as a big problem. So I'm wondering what issues it may cause...?
n

nkiesel

03/02/2017, 9:20 AM
I guess the problem is that I should be able to call an overridden method using the same parameter name as when calling the base class method. So in this sense, the parameter name (and not only the type and position) is part of the Kotlin method signature