Created
February 22, 2016 03:58
-
-
Save gkye/363da4632a0b035583fe to your computer and use it in GitHub Desktop.
shift array index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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