Swift Types & FunctionsLesson 25Free preview
Tuples & Type Aliases
This lesson is part of Swift · All levels
Summary
This lesson is about Tuple and Typealias in Swift. Tuple groups several values into one compound value while without the need to define a new struct, it is ideal for a function that returns many values. Typealias gives a new alias that makes more sense for the data type that exists.
Key points
- Tuple combines several heterogeneous-type values into one compact entity
- The tuple element can be labeled by name or accessed via a position index number (0, 1,...)
- The keyword 'typealias' gives an alternative name to the complex data type
- Very commonly used to simplify the signature closure or callback handler name
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.