Skip to content

Add to Collection interface: hasElements or equivalent #3074

@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


The most used predicate over a collection is: does it have anything in it?

But the interface provides only "does it have nothing in it", i.e. isEmpty.

This leads to lots of use of !foo.isEmpty, which is confusing as 1) it's a double negative 2) one negation happens before the main expression and the other after.

Suggestions:

 + New method, e.g. hasElements, hasItems
 + Or supplement bool some(bool f(element)) with default some((e) => true)

Discussed here:

https://groups.google.com/a/dartlang.org/d/topic/misc/MfYkrFP84dw/discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions