Skip to content

Instantly share code, notes, and snippets.

@rizumita
Created February 1, 2018 11:51
Show Gist options
  • Save rizumita/74f44951ce6fbee20646b632d4bdf344 to your computer and use it in GitHub Desktop.
Save rizumita/74f44951ce6fbee20646b632d4bdf344 to your computer and use it in GitHub Desktop.
for in vs map
let range = 0..<10000000
var i = [Int]()
test("for in") {
for n in range {
i.append(n)
}
}
print(String(i.count))
var j = [Int]()
test("map") {
j = range.map { n in n }
}
print(String(j.count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment