News for hackers. Stuff that matters.
Re:Never Use toString() for Behaviour by simendsjo on Wednesday December 04, 2019 @07:18AM (#21701530)
There's nothing wrong with returning something well-specified from toString, but I agree this should never be relied upon. And even if toString actually return something well-specified, the same functionality should be available as a distinct method.

Any form of (semi-)automatic SomeObject -> String should be treated as a convenience for the developer to avoid getting a non-descriptive memory location reported.

Having the automatic toString isn't the problem, but maybe the name of the method is. It could be called "asDebugHelpRepresentation" or something more descriptive.

There are no comments on this comment yet.