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

tschuchort

03/20/2017, 1:06 PM
why can't you use
_
as a parameter name in normal functions?
c

cy

03/20/2017, 1:10 PM
because it is reserved for unused parameter names, that feature seems to be useless for regular functions, isn't it? what is a usecase?
g

gildor

03/20/2017, 1:27 PM
Also
_
is reserved keyword in Java 9
k

kirillrakhman

03/20/2017, 1:32 PM
@cy when you override a function, you can't remove a parameter even if it's unused
c

cy

03/20/2017, 1:33 PM
why do you need to remove it?
parameter shouldn't be marked as unused if the function is overridden
k

kirillrakhman

03/20/2017, 1:34 PM
maybe you want to explicitly mark the paramerer as ignored. not a frequent usecase for me, just speculating
c

cy

03/20/2017, 1:36 PM
it is not so useful for self-documenting code because it is generally a super-type at call-site (otherwise the questions is why do you have type hierarchy at all)
o

okkero

03/20/2017, 1:36 PM
I agree with Kirill. Bar somewhat different circumstances, the use case is almost identical to that of ignored parameters in lambdas
t

tschuchort

03/20/2017, 1:41 PM
sometimes I'm overriding the function and don't really need all parameters
c

cy

03/20/2017, 1:46 PM
well, you generally don't need to type all the parameters as Ctrl-O does it for you 😉
k

kirillrakhman

03/20/2017, 1:47 PM
pft, typing is so 2006 😄
my argument was about reading
c

cy

03/20/2017, 1:53 PM
Omitting parameters also has a disadvantage: when you read it you can't see what was omitted and why