1
00:00:01,070 --> 00:00:02,040
Hey everybody.

2
00:00:02,040 --> 00:00:04,130
Welcome back to the voting party.

3
00:00:04,140 --> 00:00:06,620
Mark Price here at death's slopes of duck farm.

4
00:00:06,660 --> 00:00:14,280
And today we're going to talk about dictionaries and what I'd like you to do before we start is actually

5
00:00:14,280 --> 00:00:23,040
do me a favor and do a google search type in how do hash tables work in computer science how to hash

6
00:00:23,040 --> 00:00:28,440
tables work in computer science and go read some articles and start getting an idea of what a hash table

7
00:00:28,440 --> 00:00:33,450
is and then pauses video and go do that and come back here like in 15 minutes because I want you to

8
00:00:33,450 --> 00:00:35,820
have a base foundation.

9
00:00:35,820 --> 00:00:36,840
Did you do that.

10
00:00:36,840 --> 00:00:41,460
I'm sure you didn't because you listened to me until you start getting those job interviews and then

11
00:00:41,460 --> 00:00:42,960
they're like how does this work.

12
00:00:42,960 --> 00:00:48,030
You're like Mark you're right this whole time I should have been listening to what I just said and read

13
00:00:48,030 --> 00:00:49,640
about this and this and that and that.

14
00:00:49,650 --> 00:00:52,830
But instead I just was hoping that you had a video on it and whoa.

15
00:00:52,980 --> 00:00:54,690
But anyway I went to read it and I got the job.

16
00:00:54,780 --> 00:00:56,730
As always happens.

17
00:00:56,970 --> 00:00:57,640
Don't listen to me.

18
00:00:57,660 --> 00:00:59,130
Listen to me.

19
00:00:59,130 --> 00:00:59,530
Whatever.

20
00:00:59,550 --> 00:01:01,110
Do whatever you want your life.

21
00:01:01,110 --> 00:01:01,620
All right.

22
00:01:01,770 --> 00:01:07,810
So creating a new playground here and we're going to call this one dictionary.

23
00:01:08,370 --> 00:01:09,560
Dictionaries.

24
00:01:09,580 --> 00:01:16,590
So in Swift's hash table it's called the dictionary and in different languages the hash tables are hash

25
00:01:16,590 --> 00:01:19,850
maps or in this case dictionary here.

26
00:01:20,700 --> 00:01:24,350
And I'm going to go ahead and store this in my dictionaries folder.

27
00:01:25,100 --> 00:01:25,940
OK.

28
00:01:26,580 --> 00:01:31,690
There's a playground and I'm a pull up in this nice little info graphic that Apple has created.

29
00:01:32,010 --> 00:01:36,330
So there are three major collection types in swift.

30
00:01:36,510 --> 00:01:41,070
We have the array K which is N which is an ordered set.

31
00:01:41,370 --> 00:01:48,900
Excuse me an ordered list of items and you can have multiple values of the same type in an array.

32
00:01:48,900 --> 00:01:55,200
So for instance index 0 can have let's say the word six eggs but also index 5 could have the exact same

33
00:01:55,200 --> 00:01:55,710
word.

34
00:01:56,070 --> 00:01:57,260
Six makes doesn't matter.

35
00:01:57,390 --> 00:02:00,460
OK a linear list ordered items.

36
00:02:00,480 --> 00:02:01,090
OK.

37
00:02:01,410 --> 00:02:03,090
Now we've got something called a set.

38
00:02:03,150 --> 00:02:11,450
Now a set is has items that should only have one type of value meaning the values need to be unique

39
00:02:11,670 --> 00:02:12,680
but they're not ordered.

40
00:02:12,690 --> 00:02:14,730
OK but they are unique.

41
00:02:14,730 --> 00:02:16,950
And then we've got this cool thing here called the dictionary.

42
00:02:17,010 --> 00:02:19,800
Now you're going to use dictionaries and arrays more than your sets.

43
00:02:19,800 --> 00:02:24,730
When you're working with swift The dictionary has keys and values.

44
00:02:24,930 --> 00:02:30,420
And we're going to have an example similar to this today basically where the key is of a certain type.

45
00:02:30,570 --> 00:02:35,610
And then there is a value that's related to that key so that the values can all be the values can be

46
00:02:35,880 --> 00:02:41,080
the same as the other values of the other keys but the keys must always be unique.

47
00:02:41,250 --> 00:02:41,560
OK.

48
00:02:41,560 --> 00:02:43,130
And this is not ordered.

49
00:02:43,290 --> 00:02:43,940
OK.

50
00:02:44,160 --> 00:02:50,730
And there are actually very complex and efficient algebra algorithms working under the hood that help

51
00:02:50,730 --> 00:02:52,500
you retrieve and fetch items.

52
00:02:52,500 --> 00:02:55,900
Imagine if you had a dictionary that had a million keys in it.

53
00:02:55,920 --> 00:02:59,350
You know it's not going to go through the entire list of keys.

54
00:02:59,490 --> 00:03:04,530
It's going to start breaking things down and segregating out sections until it finds the key and the

55
00:03:04,530 --> 00:03:05,100
fastest route.

56
00:03:05,100 --> 00:03:07,620
Very complex things going underneath the hood.

57
00:03:07,620 --> 00:03:12,460
Again if you do that search I told you too on how to hash tables work.

58
00:03:12,510 --> 00:03:17,340
There's some amazing YouTube videos on how this actually works underneath the hood if you're into that

59
00:03:17,340 --> 00:03:18,110
kind of thing.

60
00:03:18,270 --> 00:03:22,770
And anyway so we're going to be working with the dictionary today and we're going to work with keys

61
00:03:22,830 --> 00:03:23,740
and values.

62
00:03:24,060 --> 00:03:27,900
So this is straight out of the Swift books with three e-book.

63
00:03:27,960 --> 00:03:30,320
Very important that you read that book.

64
00:03:30,510 --> 00:03:32,060
Of course I've said that before.

65
00:03:32,490 --> 00:03:34,410
And here we go.

66
00:03:34,500 --> 00:03:43,320
We're going to create our first dictionary names of this and I want I want you to do names of integers.

67
00:03:43,470 --> 00:03:52,950
Let's say we want a dictionary that lets us give a word a visual word that you can print out for a number

68
00:03:52,950 --> 00:03:58,620
type meaning like let's say I want the number three to say the word Three things like that.

69
00:03:58,620 --> 00:04:08,730
So what I can do is I can say names of integers equal or subscript here the square brace here and we're

70
00:04:08,730 --> 00:04:14,700
going to say three equals three.

71
00:04:14,700 --> 00:04:15,740
Now I know what you're thinking.

72
00:04:15,840 --> 00:04:17,810
Oh this is just like an array.

73
00:04:17,840 --> 00:04:19,650
This is like the third index right.

74
00:04:19,650 --> 00:04:21,220
No it is not.

75
00:04:21,240 --> 00:04:22,230
No it is not.

76
00:04:22,230 --> 00:04:26,880
This is actually the name of the key I just made the names of the keys of type int.

77
00:04:26,890 --> 00:04:31,980
OK this has nothing to do actually with an array it's not a subscript in that.

78
00:04:32,010 --> 00:04:34,170
You're grabbing an ordered amount of items.

79
00:04:34,170 --> 00:04:34,570
OK.

80
00:04:34,650 --> 00:04:39,270
This is just happened to be what I the type I chose for the key.

81
00:04:39,270 --> 00:04:41,880
This could also have been a string here which is interesting.

82
00:04:41,910 --> 00:04:46,200
So this is a simple example of your very first dictionary.

83
00:04:46,380 --> 00:04:50,670
And what we're doing here is we're just creating one on the fly.

84
00:04:50,670 --> 00:04:52,590
Initializing it using type inference.

85
00:04:52,590 --> 00:04:53,060
OK.

86
00:04:53,190 --> 00:04:57,750
We're creating a dictionary with a key of type and and a value of type string.

87
00:04:57,750 --> 00:05:01,990
I would not be able to do something like this and a three in here.

88
00:05:02,010 --> 00:05:02,530
OK.

89
00:05:02,660 --> 00:05:10,410
Because the value needs to be a string can assign value of type and destroying cast of keys and values.

90
00:05:10,470 --> 00:05:15,980
All of this may look familiar to you if you've worked with the race names of integers or see one more

91
00:05:16,370 --> 00:05:23,800
than let's say 44 equals forty four OK.

92
00:05:23,930 --> 00:05:31,160
The idea behind this dictionary is there's a unique key and then there's a value a word value for that

93
00:05:31,160 --> 00:05:34,250
we're just explaining in words so simple example.

94
00:05:34,250 --> 00:05:36,760
If you want to click quickly clear out a dictionary.

95
00:05:36,770 --> 00:05:38,490
Empty all the items out of it.

96
00:05:38,540 --> 00:05:41,900
It's as easy as doing this.

97
00:05:42,610 --> 00:05:48,650
OK square braces colon square braces it's going to clean out all of your keys and all of your values.

98
00:05:49,160 --> 00:05:52,320
Nice and you always do a more real world.

99
00:05:52,520 --> 00:05:53,980
Example let's say we have an app.

100
00:05:54,210 --> 00:05:54,900
OK.

101
00:05:55,580 --> 00:05:59,720
And let's talk about airports of the world we want to have an app that has all the airports of the world

102
00:05:59,770 --> 00:06:04,940
well every airport can only have one unique airport code.

103
00:06:04,940 --> 00:06:11,000
Imagine if airports had the same airport codes it would be crazy like imagine if Ireland had an LAX

104
00:06:11,240 --> 00:06:17,000
Los Angeles had an L.A. X you know and Dubai had an L.A. X wouldn't work that would mess things up so

105
00:06:17,050 --> 00:06:23,210
luckily we have unique airport codes that we can use throughout the world and each one has its own name

106
00:06:23,300 --> 00:06:24,120
its own unique name.

107
00:06:24,130 --> 00:06:25,340
And you know what.

108
00:06:25,430 --> 00:06:30,140
Maybe the airport codes are different and maybe two airports can have the exact same name but that wouldn't

109
00:06:30,140 --> 00:06:32,890
matter because it has its unique code and that's the most important thing.

110
00:06:32,900 --> 00:06:34,180
But we still need the name.

111
00:06:34,220 --> 00:06:38,240
So that's the advantage of using dictionaries is the Keys have to be unique.

112
00:06:38,420 --> 00:06:40,810
They have to be listed they're not secret or dictionary.

113
00:06:41,010 --> 00:06:42,670
Some of our airports.

114
00:06:42,920 --> 00:06:48,050
And this is going to be of type string so we're going to do it in explicitly declared dictionary.

115
00:06:48,050 --> 00:06:52,290
So the key is of type string and the value is of type string.

116
00:06:52,290 --> 00:06:54,780
Now let's go ahead and initialiser here right off the bat.

117
00:06:54,830 --> 00:07:00,500
So we're going to create some dictionary literals here that we're initialising right when we declare

118
00:07:00,530 --> 00:07:01,160
as well.

119
00:07:01,430 --> 00:07:03,080
So Toronto

120
00:07:06,140 --> 00:07:06,720
can't.

121
00:07:07,040 --> 00:07:14,420
So we've just created a dictionary that comes preloaded with one element in it or one key value combination.

122
00:07:14,420 --> 00:07:18,750
But we want to do more so we're going to put a comma here and then elex.

123
00:07:18,850 --> 00:07:19,500
OK.

124
00:07:19,840 --> 00:07:25,750
And what we're going to do is say loss or Los Angeles.

125
00:07:27,290 --> 00:07:28,340
Pretty cool actually.

126
00:07:28,370 --> 00:07:33,130
Los Angeles say international.

127
00:07:33,700 --> 00:07:34,240
OK.

128
00:07:34,400 --> 00:07:37,040
So and I actually commoner's not go there.

129
00:07:37,050 --> 00:07:38,070
There we go.

130
00:07:38,590 --> 00:07:39,040
OK.

131
00:07:39,230 --> 00:07:41,270
So what is happening here.

132
00:07:41,330 --> 00:07:43,730
So we put in the key name first and then a colon.

133
00:07:43,760 --> 00:07:44,070
OK.

134
00:07:44,130 --> 00:07:48,860
The colon separates the keeping the values of the key name goes first the call and then the value the

135
00:07:48,860 --> 00:07:52,670
comma separates the elements or the combinations.

136
00:07:52,670 --> 00:07:54,610
So this is one key value combination.

137
00:07:54,620 --> 00:07:56,810
This is a second and it's separated by a comma.

138
00:07:56,810 --> 00:08:04,780
So key name colon value comma key named colon value comma key name call and value comma.

139
00:08:05,360 --> 00:08:12,410
And we didn't have to explicitly declare it like so we could have used type inference and it should

140
00:08:12,410 --> 00:08:18,720
just work out of the box for us indicating that yes this is a string key and this is a string value.

141
00:08:18,770 --> 00:08:19,400
Pretty cool.

142
00:08:19,490 --> 00:08:24,080
So now we've got our dictionary full of airports and there's some of the other things we can do with

143
00:08:24,080 --> 00:08:25,010
this.

144
00:08:25,610 --> 00:08:37,790
We can print the Air Force dictionary has it lets you some string interpellation airports that count

145
00:08:39,470 --> 00:08:44,030
airport or Osei elements items.

146
00:08:44,790 --> 00:08:52,130
OK let's make this a little bigger here so you can see it's area.

147
00:08:52,460 --> 00:08:54,500
Put the quotation to soon.

148
00:08:54,500 --> 00:08:56,510
So the airport's dictionary has two items.

149
00:08:56,510 --> 00:08:57,080
Is that true.

150
00:08:57,260 --> 00:09:02,740
Yes it is one and two guys so you can get the count of a of a dictionary.

151
00:09:02,740 --> 00:09:07,460
And what else can we do if our ports is empty.

152
00:09:07,460 --> 00:09:09,220
You can see if it's empty or not.

153
00:09:09,500 --> 00:09:17,210
And we can print the airport's dictionary is empty.

154
00:09:17,720 --> 00:09:17,970
OK.

155
00:09:17,970 --> 00:09:19,280
So you can check if it's empty.

156
00:09:19,280 --> 00:09:24,300
The simple little command and you're probably wondering well how do I add new items to a dictionary.

157
00:09:24,330 --> 00:09:30,420
Well since we're not making an ordered array where an element goes onto the back of the list we're inserting

158
00:09:30,420 --> 00:09:32,210
at a certain place we don't care about that.

159
00:09:32,210 --> 00:09:33,860
All we care about is the key.

160
00:09:34,020 --> 00:09:37,470
So we can just say airports let's add a new one.

161
00:09:37,560 --> 00:09:41,310
LHR equals London.

162
00:09:42,210 --> 00:09:47,450
So what we're doing here is we're setting LHR.

163
00:09:47,460 --> 00:09:48,500
This is the key name.

164
00:09:48,620 --> 00:09:48,990
OK.

165
00:09:49,020 --> 00:09:55,590
We're set in that unique key key value to be of the value of the type and type but the value to be London.

166
00:09:55,590 --> 00:09:56,100
OK.

167
00:09:56,190 --> 00:09:59,860
So the unique key LHR is going to be equal to London.

168
00:10:00,080 --> 00:10:00,700
Okay.

169
00:10:00,750 --> 00:10:03,270
And we just added a new element at this point in time.

170
00:10:03,650 --> 00:10:06,590
Okay well what if we want to update this or override it.

171
00:10:06,780 --> 00:10:10,680
It's just as simple as doing the exact same thing.

172
00:10:11,190 --> 00:10:12,420
Okay.

173
00:10:16,630 --> 00:10:18,820
So what we did here was whatever was in that spot.

174
00:10:18,830 --> 00:10:20,030
We've now overwritten.

175
00:10:20,080 --> 00:10:21,190
It's gone.

176
00:10:21,190 --> 00:10:22,860
So that's how you replace elements.

177
00:10:22,870 --> 00:10:27,130
That's also up to elements did it matter if one of these key names existed before or not.

178
00:10:27,130 --> 00:10:31,640
No it does not matter because it will be created the moment you assign it there.

179
00:10:31,660 --> 00:10:36,790
OK so if you're thinking well there's nothing in there and I tried to assign some to it it's going to

180
00:10:36,790 --> 00:10:37,530
give me an error.

181
00:10:37,690 --> 00:10:38,450
That's not the case.

182
00:10:38,450 --> 00:10:42,230
Not unlike in an array where if you try and grab an item that doesn't exist.

183
00:10:42,360 --> 00:10:42,780
OK.

184
00:10:42,830 --> 00:10:45,260
You get the crash you know it's different here.

185
00:10:45,280 --> 00:10:46,300
OK.

186
00:10:47,470 --> 00:10:49,690
What else let's say airport.

187
00:10:51,130 --> 00:10:53,210
Loads up here.

188
00:10:54,500 --> 00:11:01,660
All right say airports credit Nouwen dev equals slopes International.

189
00:11:01,680 --> 00:11:08,260
Didn't you guys know that Dev slopes has its own airport now and we have Wi-Fi and roller coasters and

190
00:11:08,260 --> 00:11:09,080
birthday cakes.

191
00:11:09,080 --> 00:11:10,390
It's really cool.

192
00:11:11,110 --> 00:11:15,580
And then we realized it was a dream and it doesn't exist so how do we actually remove an item completely

193
00:11:15,580 --> 00:11:22,030
we want to go gone key and everything because there is no there's Loeb's airport with cakes and Wi-Fi

194
00:11:22,030 --> 00:11:24,060
and roller coasters would be cool.

195
00:11:24,070 --> 00:11:25,520
We probably had a draft in there too.

196
00:11:25,660 --> 00:11:32,720
But my dreams are now crushed so Everts dev Beagle's Neal.

197
00:11:33,190 --> 00:11:36,280
You can set it to nil which will completely destroy and remove the item.

198
00:11:36,280 --> 00:11:38,410
It is gone.

199
00:11:39,130 --> 00:11:43,060
So I hope you're starting to see oh I can work with keys and values they're unique.

200
00:11:43,060 --> 00:11:44,480
I can do different things with them.

201
00:11:44,530 --> 00:11:45,710
You're going to use these a lot.

202
00:11:45,770 --> 00:11:47,610
Hey we're just scratching the surface here.

203
00:11:47,620 --> 00:11:53,370
You can also iterate through through and a dictionary which is cool as well.

204
00:11:53,470 --> 00:11:56,360
You can get all the keys and values out of it which we'll do right now.

205
00:11:56,370 --> 00:12:08,070
So Kalsu they're here for each airport code an airport name in airports.

206
00:12:08,250 --> 00:12:08,460
OK.

207
00:12:08,470 --> 00:12:10,710
So what we're doing here is a for loop.

208
00:12:10,840 --> 00:12:11,640
OK.

209
00:12:11,680 --> 00:12:16,470
And the for loop in this case in a dictionary it's giving us what's called a tuple.

210
00:12:16,780 --> 00:12:24,760
OK a tuple is a data type or a data construct that has one or more elements in it.

211
00:12:24,910 --> 00:12:28,500
OK so it's returning as a tuple you don't have to remember that just know how to use this.

212
00:12:28,570 --> 00:12:29,210
OK.

213
00:12:29,310 --> 00:12:34,030
And what it's going to do is it's going to pass in the key name and the value.

214
00:12:34,030 --> 00:12:37,290
I could also have said key and Val.

215
00:12:37,560 --> 00:12:37,900
OK.

216
00:12:37,900 --> 00:12:38,980
Same exact thing.

217
00:12:38,980 --> 00:12:44,080
So it's going to give us the key name and the value and it's going to go through the entire dictionary

218
00:12:44,110 --> 00:12:45,060
on each one of those.

219
00:12:45,070 --> 00:12:49,900
And there is an algorithm that goes underneath the hood that's efficient and grabbing this information

220
00:12:50,400 --> 00:12:53,410
though not as efficient as other ways of accessing information.

221
00:12:53,410 --> 00:12:59,380
In most cases one in many cases you don't want to iterate through an entire list of dictionaries if

222
00:12:59,380 --> 00:13:05,110
you want to iterate through a list of something you know maybe an array is better data structure but

223
00:13:05,320 --> 00:13:10,590
you can definitely go through here and I have before so say airport code.

224
00:13:10,770 --> 00:13:11,260
All right.

225
00:13:11,410 --> 00:13:17,710
And then we'll put up the last call in here and then we're going to say airport name.

226
00:13:18,220 --> 00:13:18,720
OK.

227
00:13:19,000 --> 00:13:23,980
So we're just going to go through and print the code in the name or the key and the value.

228
00:13:23,980 --> 00:13:24,640
And here it is.

229
00:13:24,650 --> 00:13:29,740
There's the key there is the value there's the key there is the value key and value.

230
00:13:29,740 --> 00:13:30,900
OK.

231
00:13:31,810 --> 00:13:32,950
Looking good.

232
00:13:32,950 --> 00:13:34,280
Very good.

233
00:13:34,300 --> 00:13:34,690
All right.

234
00:13:34,690 --> 00:13:39,780
So there's our airport to airport name perfect gap.

235
00:13:40,390 --> 00:13:41,190
What else can we do.

236
00:13:41,200 --> 00:13:49,480
We can also just do the keys and values individually so each airport code or we can even just say for

237
00:13:49,480 --> 00:13:53,720
each key in air port Stuckey's.

238
00:13:54,070 --> 00:13:55,240
So you can print up the key is right

239
00:14:01,680 --> 00:14:02,580
when you pass in the key

240
00:14:06,310 --> 00:14:12,040
pretty cool and we can also do the same thing with the BIOS for each vowel.

241
00:14:12,150 --> 00:14:17,710
An airport style value is now valid just a variable that I've created a constant

242
00:14:20,490 --> 00:14:20,800
you

243
00:14:24,540 --> 00:14:29,000
organise mass and bell here OK so value value value.

244
00:14:29,050 --> 00:14:31,070
So you can work with kids and values.

245
00:14:31,090 --> 00:14:33,180
The kids are unique.

246
00:14:33,320 --> 00:14:38,190
You're mostly at most of the time you're going to work with strings here Njord in your data types you

247
00:14:38,190 --> 00:14:39,240
can play around with other things.

248
00:14:39,250 --> 00:14:43,810
But one of the big uses of dictionaries is when you're working with Jaison data that you're getting

249
00:14:43,810 --> 00:14:47,980
from the Internet it's going to come down in a bundle Jae's on file and you're going to grab things

250
00:14:47,980 --> 00:14:55,730
by keys and values because Jaison is very much similar to the notion of dictionary keys and values.

251
00:14:55,870 --> 00:14:59,810
And if you don't know what I'm talking about just take a look at it right here.

252
00:14:59,890 --> 00:15:06,670
You can go to a Star Wars API that's this free API that was created on the internet that has lots of

253
00:15:07,540 --> 00:15:09,250
information on it.

254
00:15:09,370 --> 00:15:11,480
And so right here it's pulling up some space on this one.

255
00:15:11,500 --> 00:15:12,770
Luke Skywalker.

256
00:15:13,000 --> 00:15:20,440
And so this is a dictionary where the Vout are the keys are of type string.

257
00:15:20,470 --> 00:15:23,280
So here's a key called name of type string.

258
00:15:23,440 --> 00:15:28,950
So name this string Luke Skywalker the value type of this one is a string.

259
00:15:28,960 --> 00:15:32,500
Let's find one that's not a string here.

260
00:15:32,560 --> 00:15:34,870
These are all strings on here.

261
00:15:34,870 --> 00:15:40,510
Let's look at some of their other API features to show you how it's going to kind of translate in your

262
00:15:40,510 --> 00:15:41,210
code.

263
00:15:45,130 --> 00:15:46,040
Israel strings as well.

264
00:15:46,040 --> 00:15:47,020
They could also been numbers.

265
00:15:47,020 --> 00:15:55,330
This this company or this person chose to put all the values in as strings instead of numbers so that's

266
00:15:55,330 --> 00:16:00,130
really important to to understand is when you download information from the internet or Jason you have

267
00:16:00,130 --> 00:16:02,350
to abide by whatever they have created for you.

268
00:16:02,350 --> 00:16:08,260
So whereas I may have put this as a number an integer they chose to use a string for both the key and

269
00:16:08,260 --> 00:16:08,650
the value.

270
00:16:08,650 --> 00:16:11,030
There's another API that I like to work with as well.

271
00:16:11,170 --> 00:16:14,390
OK mine are active pokey API.

272
00:16:14,980 --> 00:16:18,900
OK another one that somebody put up which is kind of cool.

273
00:16:19,540 --> 00:16:21,710
And here's one perfect example so.

274
00:16:22,020 --> 00:16:24,450
So this is a dictionary object right.

275
00:16:24,610 --> 00:16:27,100
And the keys are all strings.

276
00:16:27,220 --> 00:16:29,430
But in this case the key is.

277
00:16:29,490 --> 00:16:35,260
So the key ID has a value that's a number it's an integer and base experience is an integer.

278
00:16:35,260 --> 00:16:37,960
Height is an integer is default is a boolean.

279
00:16:37,960 --> 00:16:41,220
So you can have a boolean value type.

280
00:16:41,440 --> 00:16:44,710
So this is this is interesting to look at this one on this one.

281
00:16:44,710 --> 00:16:51,950
The key name is a string but the value is an array.

282
00:16:51,970 --> 00:16:52,930
That's really interesting.

283
00:16:52,930 --> 00:16:54,160
Can we do that with swift.

284
00:16:54,190 --> 00:16:57,050
Like let's say we wanted to create nobilities.

285
00:16:57,100 --> 00:16:58,340
That's really interesting.

286
00:16:58,540 --> 00:17:02,870
Let's give it a shot and say bar let's say abilities.

287
00:17:03,090 --> 00:17:04,500
Me a dictionary right.

288
00:17:04,540 --> 00:17:15,670
So the dictionary or the bill t's dictionary is going to be a dictionary of type string.

289
00:17:16,030 --> 00:17:23,110
And then what we're going to do is we're going to say an array and the array is going to be an array

290
00:17:23,110 --> 00:17:26,360
of what can be an array of dictionaries right.

291
00:17:26,620 --> 00:17:31,480
So let's see what it does here.

292
00:17:32,650 --> 00:17:35,190
Of type string and string.

293
00:17:35,200 --> 00:17:37,770
I'm just curious.

294
00:17:37,810 --> 00:17:40,000
The syntax is wrong here.

295
00:17:40,450 --> 00:17:47,810
But anyway my point here is you can have.

296
00:17:48,580 --> 00:17:52,620
You can have different items inside of your dictionaries.

297
00:17:52,630 --> 00:17:53,830
OK.

298
00:17:54,580 --> 00:18:03,200
Such as a boolean and in OK you can do all kinds of different things with your dictionaries.

299
00:18:03,200 --> 00:18:06,830
It doesn't have to just be strings and integers.

300
00:18:07,010 --> 00:18:10,250
So lots of cool stuff.

301
00:18:10,370 --> 00:18:12,320
This is just scratching the surface here.

302
00:18:12,350 --> 00:18:12,880
OK.

303
00:18:12,920 --> 00:18:17,360
Just touching the surface if you want to get a better synopsis of how dictionaries work again do that

304
00:18:17,360 --> 00:18:22,390
Google search I told you about how to hash tables work in computer science you can also look at Jason

305
00:18:22,390 --> 00:18:23,670
to start getting a feel.

306
00:18:23,700 --> 00:18:25,480
When I said Jaison That's J S.

307
00:18:25,520 --> 00:18:31,340
Oh and get a feel of how things work with with web and how it might translate to Swift.

308
00:18:31,820 --> 00:18:32,800
And that's it.

309
00:18:32,810 --> 00:18:34,240
Lots of good information.

310
00:18:34,400 --> 00:18:36,520
So get all in and let's move on and forward.

311
00:18:36,530 --> 00:18:39,020
Mark Price does slopes dotcom at CNN.
