Skip to content

Instantly share code, notes, and snippets.

@lameroid
Created April 10, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lameroid/763568e4dd00cb7a4e1ccf02b804e056 to your computer and use it in GitHub Desktop.
Save lameroid/763568e4dd00cb7a4e1ccf02b804e056 to your computer and use it in GitHub Desktop.
operator fun <T, A, B, C> T.getSlice(first: A, last: B, step: C)
operator fun <T, A, B, C, S> T.setSlice(first: A, last: B, step: C, value: S)
and we can use them:
operator fun <T> List<T>.getSlice(first: Int = 0, last: Int = size - 1, step: Int = 1)
list[first:]
list[first:last]
list[first:last:step]
list[:last]
list[:last:step]
list[first: :step]
list[: :step]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment