concat static method

Interpolation concat(
  1. Iterable<Object> contents,
  2. FileSpan span
)

Creates a new Interpolation by concatenating a sequence of Strings, Expressions, or nested Interpolations.

Implementation

static Interpolation concat(
    Iterable<Object /* String | Expression | Interpolation */ > contents,
    FileSpan span) {
  var buffer = InterpolationBuffer();
  for (var element in contents) {
    switch (element) {
      case String():
        buffer.write(element);
      case Expression():
        buffer.add(element);
      case Interpolation():
        buffer.addInterpolation(element);
      case _:
        throw ArgumentError.value(contents, "contents",
            "May only contains Strings, Expressions, or Interpolations.");
    }
  }

  return buffer.interpolation(span);
}