Posted On: Feb 22, 2018
A tuple is used to arrange multiple values in a single compound Value. In tuple, it is not compulsory for value to be of the same type. It can be of any type.
For an instance, ("interview", 123) is a tuple having two values: one is string Type, and another one is an integer type.
To create a tuple: To create it, you should have tuple literals which are a list of values listed in tuple separated by the comma. For example, the point is a tuple created by tuple literals written in between a pair of parentheses. To change a tuple literal, use dot notation with tuple’s name and assign the desired value. Check example:
var point = (0, 0) point.0 = 10 point.1 = 15 point // (10, 15)
Never Miss an Articles from us.
Swift is an advanced language for iOS development, known for its concise and expressive syntax. It enables fast-running software and is used for developing iOS and OS X applications, making it ideal f..
In Swift, key-value pairs allow for efficient data storage and retrieval, functioning similarly to hash tables in other programming languages. Accessing values is straightforward by using the correspo..
In Swift, enums define a common type for a group of related values, enabling type-safe handling within your code. Essentially, an enum groups various related values under the same umbrella, facilitati..