December 2015
Intermediate to advanced
400 pages
13h 3m
English
To get started, create a new playground called Dictionary.playground. Declare a dictionary called movieRatings and use type inference to initialize it with some data.
Listing 10.1 Creating a dictionary
import Cocoa 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