Skip to content

Instantly share code, notes, and snippets.

@eneko
Created July 19, 2016 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eneko/7b517597a521c0da78ae54225fc117da to your computer and use it in GitHub Desktop.
Save eneko/7b517597a521c0da78ae54225fc117da to your computer and use it in GitHub Desktop.
Array.getAt(index:) - Retrieve an item from an array by index with optional result
public extension Array {
/// Retrieve an item from an array by index with optional result
/// - parameter index: Index of the item to be retrieved
/// - returns: an item by index
public func getAt(index index: Int) -> Element? {
if count > index {
return self[index]
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment