Skip to content

Matcher: extend a Predicate interface #3722

Closed
@DartBot

Description

@DartBot

This issue was originally filed by @seaneagan


If we had:

typedef bool Predicate<T>(T item);
interface Matcher<T> extends Predicate<T> {...}

instead of Matcher#matches, thus using "operator call", then the following would work:

collection.some(same(value));
collection.every(isNotNull);
collection.filter(isPositive);

Also, issue #2949 could be solved with:

switch(x) {
  match (isNegative) ...
  case (0) ...
  match (lessThan(5)) ...
  // avoid full blown Matcher since don't need mismatch messages
  match ((i) => i.isEven()) ...
  default ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.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