Posts

Showing posts with the label tuple

What is Tuple in Swift

Image
What is Tuple? A tuple is a group of zero or more values represented as one value. Tuples in Swift are like mini  structs  and should be used for storing temporary values only.  They are commonly used to return multiple values from a function call.  Tuple is value types. When you initialize a variable tuple with another one it will actually create a copy. In swift we have two types of tuples are available those are  unnamed  tuples and  named  tuples.  Unnamed Tuples In swift,  unnamed tuples  are used to group multiple values into single by using parentheses and those are need to be separated by commas.  let userData = ( "Pawan Manjani" , 200 ) print(userData.0) //Pawan Manjani print(userData.1) //200       2 .    Named Tuples In swift,  named tuples  are used to group multiple values into single by using paren...