1
00:00:00,540 --> 00:00:01,500
Hello again, everyone.

2
00:00:02,460 --> 00:00:08,730
So today we're going to talk about generic types, so now when we think of software development, one

3
00:00:08,730 --> 00:00:13,600
of the purposes is to create components that we can use over and over again.

4
00:00:14,850 --> 00:00:23,250
So, in other words, will aim to develop a structure that we design today and it's flexible enough

5
00:00:23,250 --> 00:00:26,830
to provide us with our future needs as well.

6
00:00:27,960 --> 00:00:34,710
So that's why we talk about generics, because generics are structures that allow us to work in different

7
00:00:35,100 --> 00:00:37,050
types, not just one time.

8
00:00:38,320 --> 00:00:38,640
All right.

9
00:00:38,640 --> 00:00:44,700
So we can say that it supports flexible future proof, whatever you want to say.

10
00:00:45,060 --> 00:00:46,930
That's the way I see it anyway.

11
00:00:47,460 --> 00:00:47,730
All right.

12
00:00:47,730 --> 00:00:51,080
So why don't I show you what I mean with an example?

13
00:00:52,710 --> 00:00:55,350
So I'll just write a simple function that returns a number.

14
00:00:58,040 --> 00:01:00,380
And this function takes a number as a parameter.

15
00:01:10,210 --> 00:01:14,410
And now define a variable using this function and define a number.

16
00:01:26,580 --> 00:01:29,700
I print this value on a console, run the program.

17
00:01:34,900 --> 00:01:42,730
And as you can see, the value we give, so look here, we've specified the dysfunction will take a

18
00:01:42,730 --> 00:01:43,370
number of value.

19
00:01:43,870 --> 00:01:47,820
Of course, I get an error if I write a string value.

20
00:01:47,830 --> 00:01:48,130
Right.

21
00:01:49,300 --> 00:01:55,300
And likewise, if I want to print a console string value, it needs to define a second function.

22
00:01:57,320 --> 00:02:00,380
So that means I also need to define the second function.

23
00:02:09,130 --> 00:02:15,490
So this function also takes string value and the return type is string again.

24
00:02:17,840 --> 00:02:20,600
So, again, I'll define a variable that uses this function.

25
00:02:27,190 --> 00:02:28,900
And then I'll print the console.

26
00:02:38,790 --> 00:02:40,860
So, in fact, we don't see any problems here.

27
00:02:41,790 --> 00:02:44,120
Well, mainly because there aren't any problems.

28
00:02:44,130 --> 00:02:50,210
However, as I mentioned in the beginning, the aim is not to repeat the same thing.

29
00:02:52,230 --> 00:02:55,730
We want to be able to use the structure over and over again.

30
00:02:58,650 --> 00:03:01,890
So now I'll show you by writing a third function.

31
00:03:07,080 --> 00:03:14,510
So now if you're typing the function and name will define the type this way, then again, that type

32
00:03:14,510 --> 00:03:19,340
of value to get and we'll define the type of value to return.

33
00:03:24,670 --> 00:03:33,140
So now look at our use of tea here, it comes entirely from the word type, you know, its first letter.

34
00:03:34,060 --> 00:03:38,260
Now, we can also use values like A, B and C if we want to.

35
00:03:39,940 --> 00:03:46,030
But sure enough, see how this gives us a way in.

36
00:03:50,790 --> 00:03:56,850
Now, as above, I want to print a number value to the console first, and I'm sending a number of value

37
00:03:56,850 --> 00:03:57,840
to the last function.

38
00:04:09,360 --> 00:04:14,700
So now let's send the string value to a third function and print console.

39
00:04:21,560 --> 00:04:28,520
Look at that, don't get years because we've not specified here which type we're going to work with,

40
00:04:29,840 --> 00:04:36,950
we said here that we will get a type with a letter T, but we didn't specify this type.

41
00:04:39,140 --> 00:04:43,790
So when I want to use two different types here, I can just use the same function.

42
00:04:45,860 --> 00:04:49,370
That's what using generic types are all about.

43
00:04:51,200 --> 00:04:55,640
Now, before finishing our lesson here, I do want to show you the generic structure and classes.

44
00:04:57,320 --> 00:04:59,870
I'll just write class and write name.

45
00:05:06,450 --> 00:05:09,500
Then I write the generic type that we use just before.

46
00:05:12,030 --> 00:05:20,280
So in this class, if I want, I can define a variable and use that, or we can make a function definition

47
00:05:20,760 --> 00:05:22,770
and we can continue using it here.

48
00:05:24,690 --> 00:05:33,210
And we create an object from this class, so here I specify that I will use no as a variable.

49
00:05:37,120 --> 00:05:41,230
And when I call this function now, it says I need to send a number of value.

50
00:05:55,100 --> 00:05:57,980
We stated here that there will be a No.

51
00:06:02,900 --> 00:06:06,260
Now, if we use a string here, yeah, it'll give an error.

52
00:06:11,740 --> 00:06:15,790
Because it's expecting and wanting and was going to ask us for string value.

53
00:06:17,540 --> 00:06:25,880
So you see how the logic is the same, but instead of using a definite type, we use the generic and

54
00:06:25,880 --> 00:06:29,720
then we can use different types that we want to for the same class.

55
00:06:30,740 --> 00:06:36,770
So what this does is prevents us from just doing different classes that are going to be doing the same

56
00:06:36,770 --> 00:06:37,520
thing each time.

57
00:06:38,480 --> 00:06:40,010
Who wants redundancy?

58
00:06:47,090 --> 00:06:53,600
So, sure enough, my friends, we have come to the end of this lesson, we've got rid of some repetitive

59
00:06:53,600 --> 00:06:59,060
tasks thanks to the use of the generic right.

60
00:06:59,120 --> 00:07:01,390
So take care of yourself until our next lesson.

61
00:07:03,170 --> 00:07:04,000
I'll see you then.

62
00:07:04,310 --> 00:07:05,060
Bye for now.
