Last active
August 29, 2015 14:02
-
-
Save snown/e9bd220d32fd4a53ba3d to your computer and use it in GitHub Desktop.
A little extension to Array to allow prepending an item. This is just an experiment, not necessarily the right way to do it.
This file contains 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
extension Array { | |
mutating func prepend(newitem: T) { | |
insert(newitem, atIndex: 0) | |
} | |
mutating func prepend(itemArray: Array) { | |
for (index, item) in enumerate(itemArray) { | |
insert(item, atIndex: index) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment