A Funny Thing Happened On The Way To This Array
summary
Shows concrete ways to generate fixed‑count arrays (views, random numbers) and why common tricks fail: for‑loops and map work but map misuses the domain, Array.init(repeating:) duplicates the same instance, and a Swift Evolution proposal to accept a generator is rejected. Demonstrations include a constructible protocol to call zero‑arg initializers, an Int times operator and generator approaches using AnyIterator/Sequence, and a practical Array extension with generator that creates N distinct elements — code compiles and produces fresh instances per slot.
AI-written summary · about
chapters (7)
- 0:00Start
- 2:55Iteration
- 4:12For Loop
- 4:43Map Function for the for Loop
- 16:40Sequences
- 19:07Swift Evolution
- 20:05Create Your Own Array Extension








