DEV Community

Antonio
Antonio

Posted on

Lesson 14 Discussion

  1. Why do you think arrays in Swift only support a ​collection of objects of the same type?
  2. If you create an array, and assign it to a variable, the collection that is created will be mutable. If you assign an array, its size and contents cannot be changed.

How can you access objects within an array one at a time?

  • going over arrays one element at a time is something that is a very common exercise , and to do that you’d run a counter over the length of the array and pick out each element one at a time.

How might you check if an array is empty?

  • to check if an array is empty, use Swift function "isEmpty" on the array. To check if an array is empty. The function returns a bool value. If the array is empty, "isEmpty" returns true, else false.

Top comments (0)