Treehouse Intermediate Course - Part 12 (Closures 3)
OK, so a change of plans of where I was yesterday. No matter - an entry before bed instead! Just enough to keep things ticking over. I'm then in Liverpool from Wednesday until Friday. Depending on my use of wifi/hotspot on the journey, I may be able to add in something during the journey there and/or back. Right, enough prelude and let's get going. A quick session! Start Time - 21:33 Map Standard Library Functions - certain aspects on Swift are already built in. So without the use of a closure - how to transform an array of ints so that they are doubled: let values = [ 1 , 2 , 3 , 4 , 5 ] var newArray = Array < Int >() for number in values { newArray . append (number * 2 ) } This is the alternative. let doubledArray = values . map { $0 * 2 } So interesting tech speak here. The first is the imperative approach - showing line by line instruction. The declarative - the closure one - shows the end result wi...