Skip to content

Instantly share code, notes, and snippets.

@owensd
Created July 10, 2014 23:05
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 owensd/e500384b63713aa88bb1 to your computer and use it in GitHub Desktop.
Save owensd/e500384b63713aa88bb1 to your computer and use it in GitHub Desktop.
extension Array {
func first() -> T {
return self[0]
}
func last() -> T {
return self[self.count - 1]
}
}
func reverse<T>(items: [T]) -> [T] {
if items.count == 0 {
return [T]()
}
return reverse(items[1..<items.count]) + [items.first()]
}
let items = [1, 2, 3]
reverse(items)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment