Skip to content

Instantly share code, notes, and snippets.

@jpmhouston
Last active August 8, 2016 20:20
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 jpmhouston/f25d560cbd771d0f74f3d7b2d0ce6fbd to your computer and use it in GitHub Desktop.
Save jpmhouston/f25d560cbd771d0f74f3d7b2d0ce6fbd to your computer and use it in GitHub Desktop.
Swift Array element(at:), why is this missing from the standard library?
extension Array {
func element(at index: Int) -> Element? {
return index >= 0 && index < count ? self[index] : nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment