intercalateString function

String intercalateString(
  1. String s,
  2. Iterable<String> l
)

Insert a String between other Strings and concatenate.

Implementation

String intercalateString(String s, Iterable<String> l) {
  if (l.isEmpty) {
    return '';
  } else if (s.isEmpty) {
    return concatStrings(l);
  }
  String result = '';
  List<String> copy = List.from(l);
  copy.removeLast();
  for (var v in copy) {
    result += (v + s);
  }
  result += l.last;
  return result;
}