Hello! If I have a function that takes a callback that is called with a parameter, and for some callback I do not need or use this parameter – the only way to not get warnings about this is to use a @Suppress annotation, is this correct?
Copy code
fun myCallback(@Suppress("UNUSED_PARAMETER") someValue: Int) { }
Simon Kågedal Reimer
09/19/2020, 7:23 PM
It seems I can only use
_
in a lambda...
n
Nir
09/20/2020, 12:53 AM
@Simon Kågedal Reimer that thing is really long and ugly, so potentially an alternative is to write a function, named whatever you want, that's generic and takes an argument, and uses that suppress directive
Nir
09/20/2020, 12:53 AM
Then you can suppress warnings by calling the noop function
s
Simon Kågedal Reimer
09/20/2020, 7:07 AM
Right! Yes, I agree that it's ugly. That's a pragmatic suggestion, if there are no better language constructs for this – I was surprised that you couldn't use