Skip to content

Instantly share code, notes, and snippets.

@thiagoolsilva
Last active June 13, 2018 12:06
Show Gist options
  • Save thiagoolsilva/a30a8315d2b731aa8c7601c7e70fe0a4 to your computer and use it in GitHub Desktop.
Save thiagoolsilva/a30a8315d2b731aa8c7601c7e70fe0a4 to your computer and use it in GitHub Desktop.
@JvmOverloads
fun joinStrings(
collection: Collection<String>,
separator: String = ","
): String {
val result = StringBuffer()
val firstElement = 0
for((index, word) in collection.withIndex()) {
if(index != firstElement) result.append(separator)
result.append(word)
}
return result.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment