Support repeating initializers with closures not just values

Sorry for bumping old thread, hope it's ok...

The thing that bit me in the past, was doing something like this:

let layers = Array(repeating: CALayer(), count: 5)

It took awfully long time to figure out why it wasn't working (single layer, not 5 different layers).
And once I understood it, it baffled me, why the Array() didn't have an initializer that allowed me to do the thing I intended.

It took a lot of detours in whiles and for-in loops, before stumbling on map... Yes, map would be obvious choice for those who spend their daily lives in flatmap land, but it's not obvious to those who are learning the basics.

5 Likes