Skip to content

Instantly share code, notes, and snippets.

@s3itz
Created May 7, 2016 08:24
Show Gist options
  • Save s3itz/0a9726afaa0f318af5308b8be359b067 to your computer and use it in GitHub Desktop.
Save s3itz/0a9726afaa0f318af5308b8be359b067 to your computer and use it in GitHub Desktop.
--Apple-Mail=_59C7D647-374A-400F-8319-847E1514446E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=utf-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><h2 class=3D"chapter-name" style=3D"border: 0px; font-size: =
2.8em; margin: 21px 0px 0px; outline: 0px; padding: 15px 25px; =
vertical-align: baseline; font-weight: 100;">Collection =
Types</h2><section class=3D"section" style=3D"padding: 15px 25px =
30px;"><p class=3D"para" style=3D"border: 0px; font-size: 1.4em; margin: =
0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; =
color: rgb(65, 65, 65); line-height: 20.299999237060547px;">Swift =
provides three primary&nbsp;<em style=3D"border: 0px; font-size: 14px; =
margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" =
class=3D"">collection types</em>, known as arrays, sets, and =
dictionaries, for storing collections of values. Arrays are ordered =
collections of values. Sets are unordered collections of unique values. =
Dictionaries are unordered collections of key-value =
associations.</p><figure class=3D"figure" style=3D"border: 0px; =
font-size: 10px; margin: 40px auto; outline: 0px; padding: 0px; =
vertical-align: baseline; text-align: center;"><span class=3D"caption" =
style=3D"border: 0px; font-size: 1.1em; margin: 0px 0px 8px; outline: =
0px; padding: 0px; vertical-align: baseline; caption-side: top; display: =
block; text-align: left;"></span><img alt=3D"image: =
../Art/CollectionTypes_intro_2x.png" width=3D"670" height=3D"237" =
style=3D"border: 0px; margin: 0px; outline: 0px; padding: 0px; =
vertical-align: baseline;" apple-inline=3D"yes" =
id=3D"DC1A7630-64B4-4A38-BDEE-2944DC6B2AC3" apple-width=3D"yes" =
apple-height=3D"yes" src=3D"cid:AC935685-1F4E-43F9-B22B-1CBAA547008D" =
class=3D""></figure><p class=3D"para" style=3D"border: 0px; font-size: =
1.4em; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: =
baseline; color: rgb(65, 65, 65); line-height: =
20.299999237060547px;">Arrays, sets, and dictionaries in Swift are =
always clear about the types of values and keys that they can store. =
This means that you cannot insert a value of the wrong type into a =
collection by mistake. It also means you can be confident about the type =
of values you will retrieve from a collection.</p><div class=3D"note" =
style=3D"background-color: rgb(249, 249, 249); border-width: 0px 0px 0px =
5px; border-left-style: solid; border-left-color: rgb(233, 233, 233); =
font-size: 1.2em; margin: 30px auto 35px; outline: 0px; padding: 15px =
15px 7px; vertical-align: baseline; width: 581.390625px;"><a =
name=3D"//apple_ref/doc/uid/TP40014097-CH8-NoLink_62" =
style=3D"background-color: transparent; border: 0px; font-size: 12px; =
margin: -85px 0px 0px; outline: 0px; padding: 85px 0px 0px; =
vertical-align: baseline; display: block; width: 0px; height: 0px; =
color: rgb(0, 136, 204);" class=3D""></a><aside class=3D"aside"><p =
class=3D"aside-title" style=3D"background-color: transparent; border: =
0px; font-size: 9px; margin: 0px 0px 8px; outline: 0px; padding: 0px; =
vertical-align: baseline; color: rgb(128, 128, 128); letter-spacing: =
2px; text-transform: uppercase; background-position: initial initial; =
background-repeat: initial initial;">NOTE</p><p class=3D"para" =
style=3D"background-color: transparent; border: 0px; font-size: 0.75rem; =
margin: 0px 0px 8px; outline: 0px; padding: 0px; vertical-align: =
baseline; color: rgb(65, 65, 65); line-height: 17.399999618530273px; =
background-position: initial initial; background-repeat: initial =
initial;">Swift=E2=80=99s array, set, and dictionary types are =
implemented as&nbsp;<em style=3D"background-color: transparent; border: =
0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" =
class=3D"">generic collections</em>. For more on generic types and =
collections, see&nbsp;<span class=3D"x-name" style=3D"background-color: =
transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; =
vertical-align: baseline;"><a =
href=3D"https://developer.apple.com/library/ios/documentation/Swift/Concep=
tual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP400140=
97-CH26-ID179" data-renderer-version=3D"2" =
data-id=3D"//apple_ref/doc/uid/TP40014097-CH26-ID179" =
style=3D"background-color: transparent; border: 0px; margin: 0px; =
outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(0, 136, =
204); text-decoration: none;" =
class=3D"">Generics</a></span>.</p></aside></div></section><section =
class=3D"section" style=3D"padding: 15px 25px 30px;"><a =
name=3D"//apple_ref/doc/uid/TP40014097-CH8-ID106" style=3D"border: 0px; =
font-size: 10px; margin: -85px 0px 0px; outline: 0px; padding: 85px 0px =
0px; vertical-align: baseline; display: block; width: 0px; height: 0px; =
color: rgb(0, 136, 204); font-family: Helvetica, Arial, sans-serif;" =
class=3D""></a></section></body></html>=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment