I doubt that this is possible, but I thought Id as...
# stdlib
z
I doubt that this is possible, but I thought Id ask anyway! Value classes come with a default toString that results in `Count(value=5)`; is it possible to somehow override these defaults to instead just print the value (5) instead?
c
Yes. Just override the toString() method.
a
Yes, it is possible.
z
Forgot to mention 🤦🏽‍♂️ Id like to do this for a ton of classes, so manually overriding toString isnt ideal!
a
You should start an afair with KSP
wait, hold on. KSP won't help override. Sorry
j
you could do a compiler plugin like redacted probably
👀 1
d
This may be a better topic for #language-evolution, but I'd like to see more meta-programming capability to allow for writing custom
toString
implementations that are derived from a class's values, similar to
data class
, with greater flexibility, such as specifying a different prefix or separator, or having a field using a conversion aside from
toString
(especially arrays).