Skip to content

Instantly share code, notes, and snippets.

@Eduardo-Nunes
Created February 4, 2020 19:02
Show Gist options
  • Save Eduardo-Nunes/251746939f2bfc53e541d787e1e773c0 to your computer and use it in GitHub Desktop.
Save Eduardo-Nunes/251746939f2bfc53e541d787e1e773c0 to your computer and use it in GitHub Desktop.
String with double spacing with Kotlin
fun String.doubleSpacing(): String {
var self = ""
this.forEachIndexed { index, character ->
self = if (index == 0) "$character" else "$self $character"
}
return self
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment