Create unordered key/value containers called dictionaries to store custom-indexed collections, using a variety of initializers. Inspect and modify dictionaries, and create nested dictionaries.
- [Narrator] Dictionaries are unordered containers…of key-value pairs where keys are used…to look up and set new values.…Like arrays, dictionaries should also be used…to store values of the same type.…However, each key in a dictionary must be unique.…To create a dictionary, enclose in square brackets…a comma-separated list of key-value pairs…separated by a colon.…stockPrices is inferred to be of type string keys…and double values.…Strings or numbers are typically used…for dictionary keys, and they cannot be optional.…
You can use your own custom type as a key…as long as it is hashable.…I'll explain that in more detail in the types chapter.…Dictionary values can be any type.…Mutability of a dictionary and its values…is determined by whether it's created as a variable…or a constant.…stockPrices is defined as a variable, so it's mutable.…A dictionary's type can be explicitly defined…by writing the key and value types…separated by a colon in square brackets…in the declaration.…And a dictionary that has had its type explicitly declared…
Learn how to write code, understand Swift's key concepts and best practices, and strengthen your programming problem-solving skills. Instructor Scott Gardner teaches the fundamentals, so you'll be prepared to develop applications for iOS, macOS, and other platforms. Completing this course will enable you to not only write first-class code, but to think like a Swift developer.
- Creating playgrounds
- Defining variables and constants
- Working with characters and strings
- Working with collections and groups
- Using operators and defining custom operators
- Controlling program flow
- Defining functions and closures
- Working with classes, structures, and enumerations
- Adopting protocols
Skill Level Beginner
1. Get Started
2. Variables and Constants
3. Characters and Strings
4. Collections and Tuples
6. Control Flow
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.