[
https://issues.apache.org/jira/browse/GROOVY-11692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956418#comment-17956418
]
ASF GitHub Bot commented on GROOVY-11692:
-----------------------------------------
daniellansun commented on code in PR #2247:
URL: https://github.com/apache/groovy/pull/2247#discussion_r2129556784
##########
src/main/java/org/codehaus/groovy/runtime/StreamGroovyMethods.java:
##########
@@ -568,6 +568,24 @@ public static DoubleStream doubleStream(final double[]
self) {
return Arrays.stream(self);
}
+ /**
+ * Return the size of this stream.
+ * This is a terminal operator and care should be taken
+ * with stream pipelines that have side effects or infinite streams.
+ * <pre class="groovyTestCase">
+ * assert [1, 2, 3].stream().size() == 3
+ * </pre>
+ *
+ * @param self A stream
+ * @return the count of elements in this stream
+ * @see Stream#count()
+ *
+ * @since 5.0.0
+ */
+ public static <T> long size(final Stream<T> self) {
Review Comment:
How about `public static long size(final Stream<?> self)`?
> Add a Stream#size extension method that is an alias for Stream#count
> --------------------------------------------------------------------
>
> Key: GROOVY-11692
> URL: https://issues.apache.org/jira/browse/GROOVY-11692
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> Most of our size() methods return int but I was planning to return long here
> to match Stream#count().
--
This message was sent by Atlassian Jira
(v8.20.10#820010)