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 5612bd3 draft gatherers4j blog post (minor tweaks)
5612bd3 is described below
commit 5612bd3bfb089449814ffaa37835bd19067e3b0e
Author: Paul King <[email protected]>
AuthorDate: Fri Apr 11 07:13:29 2025 +1000
draft gatherers4j blog post (minor tweaks)
---
site/src/site/blog/exploring-gatherers4j.adoc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/site/src/site/blog/exploring-gatherers4j.adoc
b/site/src/site/blog/exploring-gatherers4j.adoc
index ffe58ba..bf9a548 100644
--- a/site/src/site/blog/exploring-gatherers4j.adoc
+++ b/site/src/site/blog/exploring-gatherers4j.adoc
@@ -734,7 +734,6 @@ but you can achieve a similar thing using either
`filterWithIndex` or `tapEvery`
assert Stream.from('A'..'G')
.filterWithIndex { next, idx -> idx % 3 }
.toList() == ['B', 'C', 'E', 'F']
-{end}
// take every 3rd
assert Stream.from('A'..'G')
@@ -746,10 +745,13 @@ var result = []
Stream.from('A'..'G').tapEvery(3) { result << it }.toList()
assert result == ['C', 'F']
result = []
+{end}
----
=== dropLast, dropRight
+The `dropLast` gatherer removes the last n elements from the stream:
+
[source,groovy,subs="+macros,+attributes"]
----
{start-green}
@@ -759,6 +761,8 @@ assert abcde.stream()
{end}
----
+Groovy provides `dropRight` for this:
+
[source,groovy,subs="+macros,+attributes"]
----
{start-blue}