List vs. ForEach

  • ForEach is a view that lets you pass a collection of data to its initializer and then creates multiple "subviews" from the closure you provide.

  • List is a view that can compose multiple views together, but not necessarily views of the same type. You can simply add multiple views without any loop.

  • As a convenience, the List initializer allows you to use it just like the ForEach view in case you want to have a list consisting of a single type only.ExamForEach is a structure that computes views on demand from an underlying collection of identified data. There are three ways to initialize ForEach. Each of them might seem different, but they all shared the same purpose: defining a data and its (Hashable) identifier.

Last updated