Temporarily group multiple values of varying types using tuples. Learn how to compare tuples for equality, decompose tuples into individual values, and nest tuples.
- [Narrator] Tuples in Swift can be used…to group multiple values into a single compound value.…The group values can be of different types…and the values are ordered.…You create a tuple by writing one or more values…in a comma separated list, enclosed in parentheses.…HttpStatus200 is inferred to be a…tuple of type Int, String.…You can also explicitly declare a tuples type…by writing the types in a comma separated list,…enclosed in parentheses.…Notice in the Results sidebar,…that the tuples are numerically dot index,…such as dot zero and dot one.…
You can use that index to access…the corresponding element values in the tuple.…Just remember, it's a zero index list…so the third element is an index two, for example.…I've defined an optional tuple…that holds an Int and an optional String.…You can optionally assign a name to one or more…tuple elements in it's definition.…I've declared a playerScores tuple…that holds an array of Int…and two Strings with the assign name…firstName and lastName.…With lastName being optional.…
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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.