random poll, what do you name your unused but nece...
# random
p
random poll, what do you name your unused but necessary variables? i guess in kotlin the only situation would be in destructuring, but in java it also comes up in single input lambdas where you dont care about the input. in python i would do
_
but does java/kotlin have similar convention?
d
In Kotlin you can use
_
(and in fact the IDE will suggest you do that). In Java I usually use whatever I would normally call the variable.
_
seems to be some kind of a reserved identifier in Java, or at least using it produces a warning about it not being supported in future versions.
👆🏼 1
k
Kotlin even reserves
_
for unused parameters, you can't use it as just any variable name.
p
wow, that's smart, gj Kotlin
too bad i need to solve this in Java 🤮
a
I often just go with a single character I was gonna use anyway, like
e
or
x
or something. Iirc they reserved _ to in the future perhaps use for unused variables