Colton Idle
08/22/2023, 2:06 PMconst val SOME_KEY_NAME = "MY_KEY_NAME"
cons... pollutes everywhere else having access to this?
Option B:
companion object {
const val SOME_KEY_NAME = "MY_KEY_NAME"
}
cons... people seem to look down upon companion objects. is there a way to just share the key name privately in the class?Ruckus
08/22/2023, 2:26 PMprivate const val SOME_KEY_NAME = "MY_KEY_NAME"
makes it private to the file.
For option B:
companion object {
private const val SOME_KEY_NAME = "MY_KEY_NAME"
}
makes it private to the class.
people seem to look down upon companion objectsIt's not that companion objects are bad and should be avoided. They're just a bit heavyweight sometimes for some of the simpler use cases, and so there's some active work on finding a simpler way to handle those use cases. Until then, companion objects are fine.
Ruckus
08/23/2023, 2:34 AMColton Idle
08/23/2023, 12:48 PMRuckus
08/23/2023, 2:22 PM