- Swift Functional Programming(Second Edition)
- Dr. Fatih Nayebi
- 66字
- 2021-07-02 23:54:24
Tuples
Swift provides tuples so that they can be used to group multiple values/types into a single compound value. Consider the following example:
let http400Error = (400, "Bad Request")
// http400Error is of type (Int, String), and equals (400, "Bad Request")
// Decompose a Tuple's content
let (requestStatusCode, requestStatusMessage) = http400Error
Tuples can be used as return types in functions to implement multi-return functions as well.