Skip to content

Instantly share code, notes, and snippets.

@kenresoft
Created June 3, 2023 18:31
Show Gist options
  • Save kenresoft/09cf850155ec6193b793cfd423e65c1d to your computer and use it in GitHub Desktop.
Save kenresoft/09cf850155ec6193b793cfd423e65c1d to your computer and use it in GitHub Desktop.
Implementation of Dart join function
extension Str on List {
String joint([String separator = ""]) {
if (isEmpty) {
return "";
}
final StringBuffer buffer = StringBuffer();
for (var i = 0; i < length; i++) {
if (i > 0) {
buffer.write(separator);
}
buffer.write(this[i]);
}
return buffer.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment