Skip to content

Instantly share code, notes, and snippets.

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 DaisukeNagata/2224a2ad7ced15508c587c992abee9da to your computer and use it in GitHub Desktop.
Save DaisukeNagata/2224a2ad7ced15508c587c992abee9da to your computer and use it in GitHub Desktop.
Swift_Total_ Average
let array = [1, 2, 3, 4, 5]
let total = array.map { $0 }.reduce(.zero, +)
let average = array.map { $0 }.reduce(.zero, +)/array.count
print(total)
print(average)
@DaisukeNagata
Copy link
Author

スクリーンショット 2020-07-26 20 19 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment