Spec-Zone.ru › Dart 2

dart:core

indexWhere абстрактный метод

int indexWhere(
  1. bool test(
    1. E element
    ),
  2. [int start = 0]
)

Первый индекс в списке, удовлетворяющий заданному test.

Поиск выполняется в списке, начиная с индекса start и до конца списка. При первом обнаружении объекта o, для которого test(o) имеет значение true, возвращается индекс o.

final notes = <String>['do', 're', 'mi', 're'];
final first = notes.indexWhere((note) => note.startsWith('r')); // 1
final second = notes.indexWhere((note) => note.startsWith('r'), 2); // 3

Возвращает -1, если element не найден.

final notes = <String>['do', 're', 'mi', 're'];
final index = notes.indexWhere((note) => note.startsWith('k')); // -1

Реализация

int indexWhere(bool test(E element), [int start = 0]);

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-core/List/indexWhere.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API