takeWhile method

KtList<T> takeWhile(
  1. bool predicate(
    1. T
    )
)

Returns a list containing first elements satisfying the given predicate.

Implementation

KtList<T> takeWhile(bool Function(T) predicate) {
  final list = mutableListOf<T>();
  for (final item in iter) {
    if (!predicate(item)) {
      break;
    }
    list.add(item);
  }
  return list;
}