Spec-Zone.ru › Dart 2

dart:core

Метод lastIndexWhere

int lastIndexWhere(
  1. bool test(
    1. E element
    ),
  2. [int? start]
)

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

Ищет в списке от индекса start до 0. В первый раз, когда встречается объект o, для которого test(o) истинно, возвращается индекс o. Если start опущено, по умолчанию используется длина списка.

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

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

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

Реализация

int lastIndexWhere(bool test(E element), [int? start]);

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

Spec-Zone.ru

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