Nir
07/08/2019, 3:12 PMobject
and companion objects, philosophicallyLogger
and it's an ordinary, well behaved class, you can then have a global of type Logger
called globalLogger
(never mind details of safe initialization at the moment)object globalLogger (..) : Logger
runjorel
07/08/2019, 3:19 PMNir
07/08/2019, 3:21 PMstatic
just to have functions that are not associated with a specific objectstreetsofboston
07/08/2019, 3:33 PMstatic
like (companion) objects and functions are not only useful for maintaining a global state.
They can also be used for name-spacing/scoping of functionality.Nir
07/08/2019, 3:36 PMkarelpeeters
07/08/2019, 5:06 PMWilhelm Fitzpatrick
07/08/2019, 5:14 PMkarelpeeters
07/08/2019, 5:15 PMNir
07/08/2019, 5:33 PMobject
and companions are basically singleton enabling devices, I can't really imagine using them for anything that doesn't require a singleton.object
, keep object
itself extremely minimal.