Created
July 22, 2019 07:01
-
-
Save wotjd/8bd1f7565d3b66d18d7ead63e1c2434c 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 intArray = [1,2,3,4,5] | |
// using for loop | |
var forResult = [Int]() | |
for num in intArray { | |
forResult.append(num + 1) | |
} | |
print(forResult) // [2,3,4,5,6] | |
// using map | |
var mapResult = intArray.map { $0 + 1 } | |
print(mapResult) // [2,3,4,5,6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment