This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func performAction(first a: Int, second b: Int) -> (Int,Int,Int) | |
{ | |
return(a+b,a-b,a*b) | |
} | |
var resultTuple = performAction(first: 10, second: 20) | |
print(resultTuple.0) // 30 | |
print(resultTuple.1) // -10 | |
print(resultTuple.2) // 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = 10 | |
var b = 20 | |
(a,b) = (b,a) | |
print("a is \(a) and b is \(b)") // a is 20 and b is 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = 1 | |
var b = 2 | |
var c = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var (a, b, c) = (1, 2, 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ( _, b,c) = person | |
print(b) // Hello | |
print(c) // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let person = (10, "Hello", false) | |
let (x,y,z) = person | |
print(x) // 10 | |
print(y) // Hello | |
print(z) // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mainTuple = (name: "Jonty Rhodes", gender: "Male", department: "iOS", year: 2019) | |
print(mainTuple.name) // Jonty Rhodes | |
print(mainTuple.gender) // Male | |
print(mainTuple.department) // iOS | |
print(mainTuple.year) // 2019 | |
print(type(of: mainTuple)) // (name: String, gender: String, department: String, year: Int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var origin = (x: 0, y: 0) | |
var point = origin | |
point.x = 5 | |
point.y = 10 | |
print(origin) // (0, 0) | |
print(point) // (5, 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var point = (0, 0) | |
point.0 = 50 | |
point.1 = 100 | |
print(point) // (50, 100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(person.0) // 10 | |
print(person.1) // Hello | |
print(person.2) // false | |
print(type(of: person)) // (Int, String, Bool) |
NewerOlder