This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new f78a7f5ce2 GROOVY-11596: Additional DGM lazy iterator methods (minor
refactor - typo and one missing variant)
f78a7f5ce2 is described below
commit f78a7f5ce2c4ece31d5ce121debaeb388b3ba43f
Author: Paul King <[email protected]>
AuthorDate: Mon Apr 7 09:47:07 2025 +1000
GROOVY-11596: Additional DGM lazy iterator methods (minor refactor - typo
and one missing variant)
---
.../codehaus/groovy/runtime/DefaultGroovyMethods.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git
a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 058f822ef8..81e0f076f6 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -12026,6 +12026,20 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
return result;
}
+ /**
+ * Repeat the elements from an iterable infinitely.
+ *
+ * <pre class="groovyTestCase">
+ * assert ['a', 42].repeat().take(5).collect() == ['a', 42, 'a', 42, 'a']
+ * </pre>
+ *
+ * @param self an Iterable
+ * @return an iterator containing the (infinite) repeated elements
+ */
+ public static <T> Iterator<T> repeat(Iterable<T> self) {
+ return repeat(self.iterator());
+ }
+
/**
* Repeat the elements from an iterator.
*
@@ -12049,7 +12063,7 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
* </pre>
*
* @param self an Iterable
- * @return a collection containing the repeated elements
+ * @return an iterator containing the (infinite) repeated elements
*/
public static <T> Iterator<T> repeat(Iterator<T> self) {
return new RepeatIterator<>(self);