allan.conda
08/25/2022, 7:05 AMtoString to the value? We’ve had issues where wrapping a primitive to an inline class requires checking all usages of it specially when the primitive value is already being passed directly as a String.
Wondering if anyone is doing it by default.Sam
08/25/2022, 8:03 AMtoString for anything other than debugging/logging is something I try to avoid, to be honest. Better to have a separate dedicated conversion method for anything that has a specific, well-defined string representation.Sam
08/25/2022, 8:03 AMphldavies
08/25/2022, 8:29 AMtoCanonicalRepresentation or something slightly less verboseKlitos Kyriacou
08/25/2022, 9:46 AMtoString, the way you should do it should depend on what the inline class represents, rather than what it holds.
For example, say you are currently holding a list of strings representing IP addresses, such as listOf("123.45.6.7", ...). You decide to optimize it using an inline class holding an Int. You should then make the toString print the original (traditional) representation of the IP address rather than the Int itself.