Skip to content

An interface to define custom pretty print to any objects? #35

@ndac-todoroki

Description

@ndac-todoroki

Sometimes I want to print custom outputs from certain classes.

data class Foo(val key: Int, val value: List<Int>) {
   override fun toString(): 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions