Skip to content

Instantly share code, notes, and snippets.

@alexbosworth
Created April 24, 2015 05:45
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 alexbosworth/e5506923941800d58500 to your computer and use it in GitHub Desktop.
Save alexbosworth/e5506923941800d58500 to your computer and use it in GitHub Desktop.
// Find the index of the first element found in a collection
func findInCollection<T: CollectionType where T.Generator.Element: Equatable>(collection: T, val: T.Generator.Element...) -> T.Index? {
for v in val { if let index = find(collection, v) { return index } }
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment