Skip to content

Instantly share code, notes, and snippets.

@abdurahmanadilovic
Created January 20, 2018 21:29
Show Gist options
  • Save abdurahmanadilovic/e6210ea5706f1d64c36bb605214ea50d to your computer and use it in GitHub Desktop.
Save abdurahmanadilovic/e6210ea5706f1d64c36bb605214ea50d to your computer and use it in GitHub Desktop.
Swap extension function with generics
fun <T> MutableList<T>.swap(index1: Int, index2: Int) {
val tmp = this[index1] // 'this' corresponds to the list
this[index1] = this[index2]
this[index2] = tmp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment