Notwithstanding the advice from Sam and Phil, if you still want to override
toString
, 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.