Skip to content

Instantly share code, notes, and snippets.

@theerasan
Created February 2, 2018 14:11
Show Gist options
  • Save theerasan/db2c48a57c023346910c0ecb226b11a3 to your computer and use it in GitHub Desktop.
Save theerasan/db2c48a57c023346910c0ecb226b11a3 to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
println("IPHONE AND ANDROID".reverseSentence())
}
private fun String.reverseSentence(): String {
val words = this.split(" ")
return words.map { it.reversed() }.joinToString { it }.replace(",", "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment