Hacker News new | ask | show | jobs
by favorited 1559 days ago
> swift UI both had to add language features just to support if and loop expressions

The special syntax for loops in SwiftUI is important, because plain-old loops are always eager. For example, if you were building building a list using a loop, it would iterate over every item up-front to generate the list's body. With the `ForEach` struct, on the other hand, you provide the block to create each item, and it can be invoked lazily as the content will appear.