Created
February 1, 2018 11:51
-
-
Save rizumita/74f44951ce6fbee20646b632d4bdf344 to your computer and use it in GitHub Desktop.
for in vs map
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
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