Dart Iterable  join()

Dart Iterable join()

·

1 min read

join()

  • 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

void main() {
  var parts = ['apple', 'banana', 'orange'];
  var result = parts.join(', '); 
  print(result); // Output: apple, banana, orange

  var one = ['jeet', 'sahil', 'keel'];
  var answer = one.join(',' + ' '); // Uses a string
  print(answer);
}
apple, banana, orange
jeet, sahil, keel

Exited.