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 c56db5e add loop index var
c56db5e is described below
commit c56db5e73af0b54284a0f31a81701f0309bfe127
Author: Paul King <[email protected]>
AuthorDate: Tue May 13 22:41:58 2025 +1000
add loop index var
---
site/src/site/releasenotes/groovy-5.0.adoc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/site/src/site/releasenotes/groovy-5.0.adoc
b/site/src/site/releasenotes/groovy-5.0.adoc
index 39a6496..6228ab8 100644
--- a/site/src/site/releasenotes/groovy-5.0.adoc
+++ b/site/src/site/releasenotes/groovy-5.0.adoc
@@ -783,6 +783,20 @@ var (x, y) = [1, 2]
assert x == 1 && y == 2
----
+=== Support for an index variable in loops
+
+You can now declare an index variable in a for loop definition:
+
+[source,groovy]
+----
+var list = []
+var hearts = ['💙', '💚', '💛', '💜']
+for (int idx, var heart in hearts) {
+ idx.times { list << heart }
+}
+assert list.join() == '💚💛💛💜💜💜'
+----
+
=== String utility method
There is now a utility method to produce simple ascii-art barcharts. The
following code: