Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:collection
  3. ListBase<E>
  4. where method
where
description

where method

Iterable<E>where(
  1. booltest(
    1. Eelement
    )
)
override

Creates a new lazyIterable with all elements that satisfy thepredicatetest.

The matching elements have the same order in the returned iterableas they have initerator.

This method returns a view of the mapped elements.As long as the returnedIterable is not iterated over,the supplied functiontest will not be invoked.Iterating will not cache results, and thus iterating multiple times overthe returnedIterable may invoke the suppliedfunctiontest multiple times on the same element.

Example:

final numbers = <int>[1, 2, 3, 5, 6, 7];var result = numbers.where((x) => x < 5); // (1, 2, 3)result = numbers.where((x) => x > 5); // (6, 7)result = numbers.where((x) => x.isEven); // (2, 6)

Implementation

Iterable<E> where(bool test(E element)) => WhereIterable<E>(this, test);
  1. Dart
  2. dart:collection
  3. ListBase<E>
  4. where method
ListBase class

[8]ページ先頭

©2009-2025 Movatter.jp