Skip to content

Instantly share code, notes, and snippets.

@albodelu
Forked from Atternatt/StringExample.kt
Created September 21, 2017 04:56
Show Gist options
  • Select an option

  • Save albodelu/b56df7040aba4eb533e7d0e2d5a12129 to your computer and use it in GitHub Desktop.

Select an option

Save albodelu/b56df7040aba4eb533e7d0e2d5a12129 to your computer and use it in GitHub Desktop.
Operator Overloading
operator fun String.get(intRange: IntRange): String {
return this.substring(intRange)
}
val firstSentence = "hello Marc!"
val secondSentence = "World Wide"
val mixedSentence = firstSentence[0..4] + secondSentence[0..4]
//Hello World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment