Skip to content

Instantly share code, notes, and snippets.

@gchriswill
Created January 19, 2018 22:18
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 gchriswill/2a3b36c69f2cede12a35d4e73f132927 to your computer and use it in GitHub Desktop.
Save gchriswill/2a3b36c69f2cede12a35d4e73f132927 to your computer and use it in GitHub Desktop.
Swift 4 Extension for finding the biggest integer value from an array of integers
extension Array where Element: SignedInteger {
static func findMaxInt(arr:[Int]) -> Int{
var previous = Int()
var max = Int()
arr.forEach { (n) in
max = n > previous && n > max ? n : max
previous = n;
}
return max
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment