skipEveryNth method
Skips every n-th element. n must be positive.
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
Iterable<T> skipEveryNth(int n) {
// Same positivity guard as takeEveryNth: a non-positive n has no valid
// periodic selection.
if (n < 1) throw ArgumentError(_kErrNPositive, _kParamN);
// Exact complement of takeEveryNth: drop the positions it would keep
// (index % n == 0, including the first element) and yield the rest.
return zipWithIndex().where(((int, T) p) => p.$1 % n != 0).map(((int, T) p) => p.$2);
}