Last active
September 10, 2016 20:03
-
-
Save suraphanL/5a912377eac9182ceb4b02de418cced9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var total = 0 | |
for num in intArray { | |
total = total + num | |
} | |
let totalByReduce = intArray.reduce(0) { total, num in total + num } | |
let totalByReduceShortHand = intArray.reduce(0, combine: { $0 + $1 }) | |
let shortReduce = intArray.reduce(0, combine: +) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment