Miguel Vargas
12/15/2021, 5:51 PMCanBeParameter
inspection annoying. That’s the one that warns when you can remove val
from a constructor param. As I move code around in a class I’m having to arbitrarily change wether I need val
or not. But as far as I can tell there is no benefit for private vals. Before I disable the inspection i’m wondering what am I missing?Emil Kantis
12/15/2021, 6:18 PMval
must always be stored, whereas the non-val
is just a parameter when constructing the instance and then discarded?Miguel Vargas
12/15/2021, 6:26 PMEmil Kantis
12/15/2021, 6:28 PMMiguel Vargas
12/15/2021, 6:29 PMEmil Kantis
12/15/2021, 6:32 PMJacob
12/16/2021, 4:15 PMJacob
12/16/2021, 4:16 PMMiguel Vargas
12/16/2021, 7:12 PMMiguel Vargas
12/16/2021, 7:15 PMclass Foo (a: Int) {
private val b = a // can access here
private fun c() = a // cannot access here
}
Seems arbitrary. And no developer is going to be stopped from using a
in fun c()
they’ll just change a
to val
as soon as they need it.