This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new be6b55d  add to Groovy 6 release notes: GROOVY-11893
be6b55d is described below

commit be6b55d128dc113ef669681fd031ea935ef57ae9
Author: Paul King <[email protected]>
AuthorDate: Mon Apr 13 17:16:38 2026 +1000

    add to Groovy 6 release notes: GROOVY-11893
---
 site/src/site/releasenotes/groovy-6.0.adoc | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/site/src/site/releasenotes/groovy-6.0.adoc 
b/site/src/site/releasenotes/groovy-6.0.adoc
index 7320c72..f792b9b 100644
--- a/site/src/site/releasenotes/groovy-6.0.adoc
+++ b/site/src/site/releasenotes/groovy-6.0.adoc
@@ -238,6 +238,33 @@ def result = [a:1,b:2,c:3,d:4].groupBy { it.value % 2 }
 assert result == [0:[b:2, d:4], 1:[a:1, c:3]]
 ----
 
+== Customisable Object Display with `groovyToString`
+
+Groovy 6 introduces a `groovyToString()` protocol
+(https://issues.apache.org/jira/browse/GROOVY-11893[GROOVY-11893])
+that lets classes control how their instances appear in string
+interpolation, `println`, collection formatting, and other display contexts.
+
+When a class defines a `groovyToString()` method returning `String`,
+Groovy uses it instead of `toString()` for display purposes:
+
+[source,groovy]
+----
+class Foo {
+    String toString() { 'some foo' }
+    String groovyToString() { 'some bar' }
+}
+
+assert "${new Foo()}" == 'some bar'
+assert [foo: new Foo()].toString() == '[foo:some bar]'
+----
+
+Groovy also provides built-in `groovyToString` extension methods for
+collections, maps, ranges, and primitive arrays, giving them their
+familiar Groovy formatting (e.g. `[1, 2, 3]` for `int[]` rather than
+Java's `[I@hashcode`). These can be selectively disabled using the
+`groovy.extension.disable` system property if needed.
+
 == Grape: Dual Engine Support (Incubating)
 
 Groovy 6 introduces a major evolution of the Grape dependency management system

Reply via email to