Skip to content

Collection#find method #3948

Closed
Closed
@DartBot

Description

@DartBot

This issue was originally filed by @seaneagan


A method on Collection to find the first of it's elements which matches a predicate would be useful:

E find(bool predicate(E item)) {
  var filtered = filter(predicate);
  if(filtered.isEmpty) return null; // throw instead ?
  return filtered.iterator().next();
};

it might also make sense to rename Collection#filter to Collection#findAll since "filter" seems to have a mutative connotation.

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions