Checking the number of elements in a dictionary

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

// count returns the number of items in a dictionary
contactList.count

2 is displayed in the Results area.

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

// isEmpty returns true if a dictionary is empty
contactList.isEmpty

false is displayed in the Results area.

Now, let's see how to add new items to a dictionary.

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

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