Arrays
Arrays are an ordered collection of values and can hold any number of items. For example, a list of Strings, Ints, floating-point values, and so on. Arrays are stored in an ordered list, starting at 0. Let's look at a diagram:
Starting from left to right in the preceding examples, we first have an array that holds a collection of Strings. In the second example, we have another array that holds a collection of Ints. In our third example, we have an array that holds a collection of floating-point values.
Now, let's review the following diagram that looks like an array, but actually is not one:
Since this example contains mixed data types, such as Strings, Ints, and bools, it is not considered an array. If you enter this, you will receive an error message.
An array can hold any data type, but since an array is strongly typed, every element in it must be of the same type.
Creating an empty array
Let's now create a few arrays in Playgrounds.
Sometimes, you may want to remove your prior entries...