1
00:00:00,450 --> 00:00:07,110
So I come again in business and you're going to talk about structures what this structure is is actually

2
00:00:07,110 --> 00:00:09,310
very very similar to a class.

3
00:00:09,330 --> 00:00:13,880
And if you already know how to use classes you can tell yourself that you already know how to use a

4
00:00:13,880 --> 00:00:15,040
struct as well.

5
00:00:15,210 --> 00:00:18,310
So just going to ex-coach and see how you're going to do that.

6
00:00:18,330 --> 00:00:19,510
I'm going with ex-school.

7
00:00:19,890 --> 00:00:26,900
I'm going to start a new command line to our swift language and I'm going to call it a struct.

8
00:00:26,910 --> 00:00:35,250
It's said so in here I'm going to go ahead in my mane and say do this.

9
00:00:35,480 --> 00:00:40,890
I have a struct or nothing that struct call the user.

10
00:00:41,170 --> 00:00:49,400
And then it has this variable name which happens to be a string and a value of value ID which again

11
00:00:49,400 --> 00:00:51,110
happens to be a string.

12
00:00:51,110 --> 00:00:53,030
It feels very very familiar.

13
00:00:53,030 --> 00:00:53,760
Right.

14
00:00:53,780 --> 00:00:55,010
It's just like a class.

15
00:00:55,010 --> 00:01:00,540
I would also have an initializer in name which is a string.

16
00:01:00,710 --> 00:01:11,170
I could have him you ID which is this string and I would say self-taught name becomes input name self

17
00:01:11,350 --> 00:01:14,670
you ID the comms input you ID.

18
00:01:14,720 --> 00:01:19,210
Now you might be wondering well this is kind of identical to a class.

19
00:01:19,240 --> 00:01:23,010
Why are you using this over the other one or vice versa.

20
00:01:23,240 --> 00:01:27,120
Here are the two things that are different between them.

21
00:01:27,170 --> 00:01:37,250
First of all destructs can not have inheritance inheritance for starters like that child that gets left

22
00:01:37,250 --> 00:01:37,810
behind.

23
00:01:37,830 --> 00:01:44,930
Nobody gives him anything no inheritance so if you try to make user a member of the string is actually

24
00:01:44,930 --> 00:01:51,320
going to give you an error saying that hey why are you trying to do is Throgs can not have subclassing

25
00:01:51,320 --> 00:01:53,340
or they cannot inherit from anyone.

26
00:01:53,570 --> 00:02:04,670
That's part of one part too and this is a very important one part to instruct past value while classes

27
00:02:05,270 --> 00:02:15,890
pass the pointer or the memory location because of that the strokes are a lot faster or a lot faster.

28
00:02:15,970 --> 00:02:21,650
Not a lot of discussions online about which one is better and why you should use this one or the other

29
00:02:21,650 --> 00:02:22,150
one.

30
00:02:22,220 --> 00:02:28,490
I have my own really specific set of you know personal favorites and I would actually go to the link

31
00:02:28,490 --> 00:02:34,070
for you guys to a long discussion on a stack overflow which I really commend you guys at least trying

32
00:02:34,070 --> 00:02:37,460
to skim through it get some sense of what the guys are suggesting.

33
00:02:37,580 --> 00:02:47,470
But heres a rule of thumb for you use destructs unless you need classes.

34
00:02:47,570 --> 00:02:51,110
So as long as you can get away with this Throgs just use them.

35
00:02:51,350 --> 00:02:55,490
If you have a reason to use classes then you must go for class.

36
00:02:55,490 --> 00:03:02,660
The reason I started with classes is simply because classes are like a fundamental part of object oriented

37
00:03:02,660 --> 00:03:03,440
programming.

38
00:03:03,470 --> 00:03:06,350
And we kind of needed to get started with those.

39
00:03:06,440 --> 00:03:12,770
But in practice whatever you want to do if you can use a structure for it just use that and you dont

40
00:03:12,770 --> 00:03:14,010
need to go for classes.

41
00:03:14,030 --> 00:03:20,840
But if youre doing something like are propertyless thing application that there has to be inheritance

42
00:03:20,840 --> 00:03:24,530
between different classes and objects then you need to go with classes.

43
00:03:24,560 --> 00:03:27,830
Otherwise for most everything you can use a struct.

44
00:03:27,850 --> 00:03:30,490
And stocks are a lot lot faster.

45
00:03:30,770 --> 00:03:36,260
So with that in mind once again I really encourage you to read the posts that I have in the description

46
00:03:36,260 --> 00:03:38,860
of this lesson on this one.
