My only hesitation is that "count" seems like an imperative to me, and it's not obvious that "size" will both evaluate and exhaust (if possible) a stream. Streams aren't quite like other aggregate objects.
On Wed, Jun 4, 2025, 18:12 Paul King <pa...@asert.com.au> wrote: > In StreamGroovyMethods, I created a size() method for Stream that is > an alias for count(): > > https://github.com/apache/groovy/pull/2247 > > (Suggested on Slack by Vampire aka Björn Kautler) > > Let me know if you have any feedback. One of the pain points Groovy > proposes to offer is always having a size() method on an aggregate > thing and relieving the developer from having to know whether that > thing offers size(), length, length(), count() and other options. So, > I am +1 on adding this in Groovy 5. It appears to me to be like a > missing feature we didn't spot for earlier Groovy versions, so I am > thinking we should backport to GROOVY_4_0_X. Thoughts? > > Cheers, > Paul. >