Checking the number of elements in an array

To find out how many items there are in an array, use count. Type and run the following code:

// count returns the number of items in an array
shoppingList.count

2 is displayed in the Results area.

You can check whether an array is empty by using isEmpty. Type and run the following code:

// isEmpty returns true if an array is empty
shoppingList.isEmpty

false is displayed in the Results area.

Now, let's see how to add items to arrays.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.226