Skip to content

Instantly share code, notes, and snippets.

@gkye
Created February 22, 2016 03:58
Show Gist options
  • Save gkye/363da4632a0b035583fe to your computer and use it in GitHub Desktop.
Save gkye/363da4632a0b035583fe to your computer and use it in GitHub Desktop.
shift array index
mutating func moveItem(fromIndex oldIndex: Index, toIndex newIndex: Index) {
insert(removeAtIndex(oldIndex), atIndex: newIndex)
}
var tags = [1,2,3,4,5,7782,25]
tags.moveItem(fromIndex: 2, toIndex: tags.count-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment