slice method

  1. @useResult
KtList<T> slice(
  1. KtIterable<int> indices
)

Returns a list containing elements at specified indices.

Implementation

@useResult
KtList<T> slice(KtIterable<int> indices) {
  if (indices.count() == 0) {
    return emptyList<T>();
  }
  final list = mutableListOf<T>();
  for (final index in indices.iter) {
    list.add(get(index));
  }
  return list;
}