November 2016
Intermediate to advanced
480 pages
14h 42m
English
To get started, create a new playground called Dictionary. Declare a dictionary called movieRatings and use type inference to initialize it with some data.
Listing 10.1 Creating a dictionary
import Cocoavar str = "Hello, playground"var movieRatings = ["Donnie Darko": 4, "Chungking Express": 5, "Dark City": 4]
You created a mutable dictionary using the Dictionary literal syntax. Your dictionary will hold movie ratings. Its keys are instances of the String type and represent individual movies. These keys map onto values that are instances of the Int type that represent individual ratings of the movies.
Read now
Unlock full access