Last active
August 29, 2015 14:02
-
-
Save langford/cb0a1edd7542600e5037 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let individualScores = [75, 43, 103, 87, 12] | |
var teamScore = 0 | |
if 75 > 50 { | |
teamScore += 3 //this makes teamScore go from 0->3 | |
} else { | |
teamScore += 1 | |
} | |
println(teamScore) //this outputs 3 | |
if 43 > 50 { | |
teamScore += 3 | |
} else { | |
teamScore += 1 //this makes teamScore go from 3->4 | |
} | |
println(teamScore) //this outputs 4 | |
if 103 > 50 { | |
teamScore += 3 //this makes teamScore go from 4->7 | |
} else { | |
teamScore += 1 | |
} | |
println(teamScore) // this outputs 7 | |
if 87 > 50 { | |
teamScore += 3 //this makes teamScore go from 7->10 | |
} else { | |
teamScore += 1 | |
} | |
println(teamScore) //this outputs 10 | |
if 12 > 50 { | |
teamScore += 3 | |
} else { | |
teamScore += 1 //this makes teamScore go from 10->11 | |
} | |
println(teamScore) // this outputs 11 | |
// | |
//The stuff above here, and the stuff below here output the same thing | |
// | |
let individualScores = [75, 43, 103, 87, 12] | |
var teamScore = 0 | |
for score in individualScores { | |
if score > 50 { | |
teamScore += 3 | |
} else { | |
teamScore += 1 | |
} | |
println(teamScore) | |
} | |
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment