Skip to content

Instantly share code, notes, and snippets.

@Li-Bot
Created March 6, 2020 06:39
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 Li-Bot/4daa413123386e686de5bda7d88903ed to your computer and use it in GitHub Desktop.
Save Li-Bot/4daa413123386e686de5bda7d88903ed to your computer and use it in GitHub Desktop.
// Swift
let sum = fahrenheit.reduce(0.0) { (result, degreesFahrenheit) -> Double in
return result + degreesFahrenheit
}
// For-in loop
var sum: Double = 0.0
for degreesFahrenheit in fahrenheit {
sum += degreesFahrenheit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment