You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I want to print custom outputs from certain classes.
data classFoo(valkey:Int, valvalue:List<Int>) {
overridefuntoString(): String { // pp() doesn't use this!return"#Foo($key => $value)"
}
}
I wish I can override what pp() uses to format class instances, for example by implementing some interface.
(overriding fun pp() is an option too, but I think it is not the best, because the implementer needs not to forget newlines)
The text was updated successfully, but these errors were encountered:
Hm. The main point of pretty-print is to avoid the toString method, because toString methods usually do not do a good job of rendering the actual structure. Once dipping down into the toString, there's then no way to jump back out to rendering things 'correctly' (like the List in this example), without either duplicating things, or messing up the formatting.
Sometimes I want to print custom outputs from certain classes.
I wish I can override what
pp()
uses to format class instances, for example by implementing some interface.(overriding
fun pp()
is an option too, but I think it is not the best, because the implementer needs not to forget newlines)The text was updated successfully, but these errors were encountered: