Question: `count()` versus `size` for collections?...
# getting-started
r
Question:
count()
versus
size
for collections? Seems there are two ways to get the number of elements in a collection:
count()
called without a predicate argument and
size
, looks like a field, attribute, property. Any reason to prefer one over the other?
d
The difference is that
count
is available for
Iterable
as well (where it will loop through the
Iterable
to count the elements). For
Collection
count
and
size
are identical.