join method

  1. @override
String join([
  1. String separator = ''
])
override

Converts each element to a String and concatenates the strings.

Iterates through elements of this iterable, converts each one to a String by calling Object.toString, and then concatenates the strings, with the separator string interleaved between the elements.

Example:

final planetsByMass = <double, String>{0.06: 'Mercury', 0.81: 'Venus',
  0.11: 'Mars'};
final joinedNames = planetsByMass.values.join('-'); // Mercury-Venus-Mars

Implementation

@override
String join([String separator = '']) {
  if (isEmpty) {
    return '';
  }
  final buffer = StringBuffer();
  buffer.write(elementAt(0));
  for (var i = 1; i < length; i++) {
    buffer.write(separator);
    buffer.write(elementAt(i));
  }
  return buffer.toString();
}