Tuples are a great addition to Swift. It provides the ability for functions to return multiple values. In Objective-C and other languages, we need to use either custom objects or array of objects to return multiple values. Tuples helps us overcome this.

Syntax

func functionName(parameters with types)->(return values with types)

Example

func mathOperations(number1:Int ,number2:Int)->(add:Int ,sub:Int, mul:Int, div:Int )
{
return (number1+number2, number1-number2, number1*number2, number1/number2)
}

Calling a function

var a:(Int ,Int, Int, Int ) = mathOperations(1,number2: 2)
println("\(a.0)\(a.1)\(a.2)\(a.3)") 

Output

3 -1 2 0