Collection of Variables

Array

initialize, append, remove(at

Dictionary

Set

Stuct

Enum

Tuples

A tuple is a collection of variables enclosed within parentheses. They can be used to return multiple values from a function. For example
return (x, y, z)
returns values x, y and z from the function. Another approach might be to use an array.

Tuples can also be useful in switch statements. For example.

switch (one, two)
{
case (0,0):
	return 1
case (1,_):
	return 2
case (_,2):
	return 3
default:
	return 4
}
If one and two equal zero return 1. If one is 1 and two is any number return 2. If one is any number and two is 2 return 3. Otherwise return 4 as the default.

Index


Comments, Corrections, Suggestions: David Bourne (david@boomer.org)
My iOS and tvOS Apps and iBooks