Enumerable<T>.repeat constructor

Enumerable<T>.repeat(T value, int count)

Creates an enumerable

A convenience factory to create an enumerable by repeating value count number of times.

count must be a non-negative number.

Implementation

factory Enumerable.repeat(T value, int count) {
  if (count < 0) {
    throw ArgumentError('`count` must be a non-negative integer.');
  }
  if (count == 0) return Enumerable<T>.empty();
  return RepeatEnumerable<T>(value, count);
}