Joshua Hansen
11/17/2025, 7:40 PMAssigned value is never read on aNumber += 1 even with the suppressions. I personally consider this warning wrong but I'm sure people could argue about it. Is there anyway to suppress it?
Also, why did the `Wrapped into a reference object to be modified when captured in a closure." statement go away?
class Foo(val lambda: () -> Unit)
@Suppress("UNUSED_VARIABLE", "UNUSED")
fun test() {
var aNumber = 0 // "Wrapped into a reference object..." doesn't show anymore
val newFoo = Foo {
val test = 1 + aNumber // Do something with current value
aNumber += 1 // Change value to be used next time Foo.lambda() is called
}
// do something with newFoo here to use later like add it to a list, etc.
}Bartłomiej Jończy
11/17/2025, 8:06 PMaNumber is the primitive int on JVM, so it's not referenced in newFoo initializerdmitriy.novozhilov
11/18/2025, 7:04 AM@Suppress("AssignedValueIsNeverRead") in this case).dmitriy.novozhilov
11/18/2025, 7:05 AMSNAKE_CASE
• inspections from the IDE are in CamelCaseJoshua Hansen
11/18/2025, 6:55 PMdmitriy.novozhilov
11/18/2025, 10:21 PMRob Elliot
11/19/2025, 11:19 AMclass Foo(val lambda: () -> Unit)
fun main() {
var aNumber = 0
val newFoo = Foo {
val test = 1 + aNumber // Do something with current value
aNumber += 1 // Change value to be used next time Foo.lambda() is called
println(test)
}
newFoo.lambda.invoke()
newFoo.lambda.invoke()
}
The output changes if you accept the IDE's suggestion, which is bad.Daniel Pitts
11/19/2025, 8:35 PM