groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Omitting parentheses on .size() ?
Date Sat, 01 Aug 2020 18:55:28 GMT
On 01.08.20 19:41, MG wrote:
> Hmmm, I am for consistency, but at least I use very few maps as compared
> to lists, and rarely ever output the size of a map, but constantly for
> lists, so having getSize() on List would still be beneficial.
>
> This has of course been discussed many times before - maybe a "size"
> operator:
>
> #list // list.size()
> #map // map.size()
> #string // string.length

a size() method is the way of consistency we did go for. It exists on
collection, string, array and map. We added it to string and array so
you do not to have to remember using length or length()


> which people could override (e.g. sizeOf() method) and which unifies all
> kinds of "how many elements do I hold / how big am I" concepts (if its
> not a collection holding items) ?-)

why sizeOf() if there is already size()?

bye Jochen

Mime
View raw message