padRight method

Iterable<E> padRight(
  1. int totalLength, {
  2. required E padValue,
})

Pads elements to the end of this Iterable to make it have the specified length.

If the length of this Iterable is already totalLength or greater, returns this Iterable.

Implementation

Iterable<E> padRight(int totalLength, {required E padValue}) {
  if (totalLength <= length) {
    return this;
  }

  return followedBy(
    Iterable<E>.generate(
      totalLength - length,
      (_) => padValue,
    ),
  );
}