0
1
00:00:00,590 --> 00:00:10,040
Welcome to a Swift Deep Dive on Parameter Names. Now, in Swift, the parameter names of a function are incredibly
1

2
00:00:10,040 --> 00:00:17,180
important. In the predecessor to Swift, Objective-C, which used to be the language that we used to make
2

3
00:00:17,240 --> 00:00:18,570
iOS apps,
3

4
00:00:18,710 --> 00:00:20,930
they weren't really big on parameter names.
4

5
00:00:20,930 --> 00:00:27,680
Instead, you ended up with really, really long method and function names to describe exactly what the
5

6
00:00:27,770 --> 00:00:34,610
function is supposed to do. But in Swift, it's meant to be about well-named parameters that clearly describe
6

7
00:00:34,640 --> 00:00:41,810
the functionality. And this ability of Swift methods and functions, to be really clear, relies really heavily
7

8
00:00:41,870 --> 00:00:45,720
on a particular feature of the Swift parameter names.
8

9
00:00:45,980 --> 00:00:53,230
And it's the ability to have completely separate internal and external parameter names.
9

10
00:00:53,300 --> 00:01:01,190
So in this case, instead of having a single parameter name, the word "name," we now have a external name
10

11
00:01:01,190 --> 00:01:07,190
which is the name that will refer to the parameter when we call the function, and an internal name which is
11

12
00:01:07,190 --> 00:01:12,160
the name that we'll use when we need to use the parameter within the function.
12

13
00:01:12,170 --> 00:01:18,830
So if this is what our method definition looks like, then when we call the function, we would write something
13

14
00:01:18,860 --> 00:01:26,270
like this. So in this case, the external parameter name is what we're using when we call the function, and the
14

15
00:01:26,270 --> 00:01:34,320
internal parameter name is what we use when we need to use the value of that parameter within the function.
15

16
00:01:34,370 --> 00:01:41,480
Now, you can also if you wanted to, actually omit the external parameter name altogether to be able to
16

17
00:01:41,480 --> 00:01:47,920
call your function just by passing in a value without mentioning the name of the parameter at all.
17

18
00:01:47,930 --> 00:01:49,330
So how would we do that?
18

19
00:01:49,520 --> 00:01:55,600
Well, all that we would need to do is simply turn the external parameter name into an underscore.
19

20
00:01:56,210 --> 00:02:01,000
And now we can call our function without using a parameter name at all.
20

21
00:02:01,130 --> 00:02:07,900
And instead, all we have to do is just pass in the value that we want to use as the input.
21

22
00:02:07,940 --> 00:02:14,180
So in this case, we still have an internal parameter name which we can use to refer to the value within
22

23
00:02:14,180 --> 00:02:15,040
the function.
23

24
00:02:15,140 --> 00:02:18,970
But when we call the method, we no longer have an external parameter name.
24

25
00:02:19,940 --> 00:02:25,490
So in the next lesson, we're actually going to use this in practice and we're going to update our delegate
25

26
00:02:25,490 --> 00:02:28,520
methods to be more in line with the way that Apple does things.
