Skip to content

Instantly share code, notes, and snippets.

@olxios
Last active November 29, 2016 12:55
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 olxios/c3307f4c9768b3888fcb60cc35f37d28 to your computer and use it in GitHub Desktop.
Save olxios/c3307f4c9768b3888fcb60cc35f37d28 to your computer and use it in GitHub Desktop.
Average array value
// Swift 3
let testArray: [Double] = [15.67, 9.87, 4.56, 3.45, 3.45, 8.76, 6, 1, 20.11]
let average: Double = (testArray as NSArray).value(forKeyPath: "@avg.self") as! Double
print("Average \(average)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment