Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Map
- //Loops over a collection and applies the same operation to each element in the collection.
- var numberArray = [1,2,3,4,5]
- var newArray = numberArray.map( {(value:Int) -> Int in
- return value*2
- })
- //or quicker
- var newArray = numberArray.map{$0*2}
- //newArray = [2,4,6,8,10]
Add Comment
Please, Sign In to add comment