Skip to content

Instantly share code, notes, and snippets.

@gallaugher
Created June 27, 2018 00:26
Show Gist options
  • Select an option

  • Save gallaugher/e0eb6e6f23051de91b2f66601113484b to your computer and use it in GitHub Desktop.

Select an option

Save gallaugher/e0eb6e6f23051de91b2f66601113484b to your computer and use it in GitHub Desktop.
Printing for in vs. forEachj
var scores = [83, 85, 90, 100]
// print all array elements with a for loop:
for score in scores {
print(score)
}
print("^for in ^\n")
// print all elements with forEach:
scores.forEach{print($0)}
print("^ for each ^\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment