O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required