1
00:00:01,030 --> 00:00:05,680
In this video, we're going to take a look at some alternate forms of syntax around annotations for

2
00:00:05,680 --> 00:00:06,280
functions.

3
00:00:06,830 --> 00:00:12,250
So underneath my two functions I already have, I'm going to define another one called Divide, and

4
00:00:12,250 --> 00:00:14,660
you'll notice I'm going to use the key word function right here.

5
00:00:15,190 --> 00:00:19,510
So how do we use these annotations with a function defined with a function keyword?

6
00:00:19,870 --> 00:00:21,400
Well, basically the exact same way.

7
00:00:22,000 --> 00:00:23,440
So we'll have two arguments.

8
00:00:24,370 --> 00:00:31,270
A and B, and we need to annotate both them, so we'll say A is going to be A no and B is going to be

9
00:00:31,270 --> 00:00:32,170
a number as well.

10
00:00:33,040 --> 00:00:38,620
Then to annotate the return type of this again, right after the argument list will put in a colon and

11
00:00:38,620 --> 00:00:40,450
then the type of value we expect to return.

12
00:00:41,320 --> 00:00:42,850
Then we can return.

13
00:00:43,760 --> 00:00:45,710
A divided by B like so.

14
00:00:47,490 --> 00:00:52,650
Now, his syntax is going to also work for anonymous functions assigned to variables, too, so I could

15
00:00:52,650 --> 00:00:54,210
say const multiply.

16
00:00:56,150 --> 00:00:57,080
Will be a function.

17
00:00:58,570 --> 00:01:03,250
This will take two arguments of A and B once again, both numbers.

18
00:01:05,280 --> 00:01:10,980
And again, right after that argument list, we can annotate the return type as well, and so then inside

19
00:01:10,980 --> 00:01:14,040
the function A times, B like so and that's pretty much it.

20
00:01:15,110 --> 00:01:21,710
So any time that we need to define a function using an arrow, a named function or an anonymous function

21
00:01:21,710 --> 00:01:26,050
assigned to a variable, we're always going to see a near identical form of syntax.

22
00:01:26,060 --> 00:01:29,960
It's always going to be the arguments with the colon and then the expected type.

23
00:01:30,410 --> 00:01:35,970
And then immediately after the closing parentheses, we'll do another colon and the expected type of

24
00:01:35,970 --> 00:01:37,280
the return value from the function.

25
00:01:37,500 --> 00:01:38,360
And that's pretty much it.

26
00:01:39,260 --> 00:01:42,260
OK, quick pause here and we'll talk about one last thing in the next video.

