How to extend a data class with toString
Adding a .toString() extension function would not work because: Extension functions can’t take part in virtual calls (they are resolved statically). In other words, extensions cannot override member functions. If there is a matching member function, it is preferred to the extension. If you add an extension function fun Something.toString() = …, then s.toString() won’t … Read more