chain<T> function

Iterable<T> chain<T>(
  1. Iterable<T> first,
  2. Iterable<T> second, [
  3. Iterable<T>? third,
  4. Iterable<T>? fourth,
  5. Iterable<T>? fifth,
  6. Iterable<T>? sixth,
])

Gets chained inputs from multiple iterable arguments that are evaluated lazily.

print(chain(1.to(4), [4, 5], 1.to(4)).toList());
// output: [1, 2, 3,  4, 5,  1, 2, 3]

Implementation

Iterable<T> chain<T>(
  Iterable<T> first,
  Iterable<T> second, [
  Iterable<T>? third,
  Iterable<T>? fourth,
  Iterable<T>? fifth,
  Iterable<T>? sixth,
]) {
  final elements = [
    first,
    second,
    if (third != null) third,
    if (fourth != null) fourth,
    if (fifth != null) fifth,
    if (sixth != null) sixth,
  ];
  return chain_from_iterables(elements);
}