takeOnly method

List<E> takeOnly(
  1. int n
)

Returns a list containing the first n elements.

Implementation

List<E> takeOnly(int n) {
  if (n <= 0) return [];
  if (n >= length) return toList();
  return take(n).toList();
}