1
00:00:01,370 --> 00:00:04,250
In this lesson we're going to talk about the variables.

2
00:00:04,310 --> 00:00:08,020
Everybody is essentially a container for a value.

3
00:00:08,240 --> 00:00:15,450
And since the name suggests it's a very wrong value that can be entered into that valuable variables

4
00:00:15,470 --> 00:00:20,770
are used to store different information and presented to us whenever we need them.

5
00:00:20,780 --> 00:00:26,750
But before we go that deep into understanding the role of variables in our programming language.

6
00:00:26,870 --> 00:00:33,290
Let's get a sense of some of the basic facts and then from there on we can one more advanced topics.

7
00:00:33,290 --> 00:00:38,420
So let me jump back into school and it makes for then I'm actually going to close this project and to

8
00:00:38,420 --> 00:00:39,830
start a new one.

9
00:00:39,950 --> 00:00:44,140
So file new project just like the last time I'm going to use.

10
00:00:44,150 --> 00:00:47,080
My question I'm going to use the command line tool.

11
00:00:47,530 --> 00:00:57,380
I'm going to call this long variable's project not in my variables project just like the last time I'm

12
00:00:57,380 --> 00:01:03,680
going to go to my dad and find him remove all the comments so that the code is a little bit easier to

13
00:01:04,070 --> 00:01:07,460
see and then get rid of this part of it.

14
00:01:07,700 --> 00:01:09,450
I like my presentation.

15
00:01:09,470 --> 00:01:13,100
I'm going to talk about four types of variables.

16
00:01:13,100 --> 00:01:16,180
Integers floats characters and what happens.

17
00:01:16,190 --> 00:01:29,180
So let's see what all these things so well we'll write that integers floats booleans and of course characters

18
00:01:31,220 --> 00:01:33,190
or characters.

19
00:01:33,230 --> 00:01:34,970
So let's see what they are.

20
00:01:35,030 --> 00:01:42,300
The first one is let's call it in and I'm going to call it my ends.

21
00:01:42,620 --> 00:01:45,050
Equals three for instance.

22
00:01:45,230 --> 00:01:47,010
Then I will write another one.

23
00:01:47,010 --> 00:01:55,480
And when I say floats and this one is going to be my float and that's going to be to point three and

24
00:01:55,490 --> 00:02:03,310
then I have another one card for my boolean and that is currently true.

25
00:02:03,820 --> 00:02:05,710
And then I have a cat there.

26
00:02:07,340 --> 00:02:11,960
Or my cat is the leader I see.

27
00:02:12,360 --> 00:02:16,960
So by just looking at them you can kind of get a sense of what they are.

28
00:02:17,220 --> 00:02:27,010
Integers are the whole numbers so whole numbers between if I can get the sign of infinity in

29
00:02:29,190 --> 00:02:33,150
infinity Yes I won.

30
00:02:33,150 --> 00:02:47,210
So between negative infinity and positive infinity and then float values are numbers with decimals.

31
00:02:47,490 --> 00:02:53,930
So such as three point three essentially any integer is also a float value as well.

32
00:02:53,940 --> 00:02:59,440
So this is essentially three point zero you could have twenty point zero in here.

33
00:02:59,520 --> 00:03:05,750
Boolean values are true or false or yes or no.

34
00:03:05,850 --> 00:03:12,240
So a sort of true I could use the yes I'm more used to using true because that makes more sense to me.

35
00:03:12,420 --> 00:03:21,180
And characters are essentially singular characters so integers all numbers float values that they have

36
00:03:21,180 --> 00:03:29,400
a decimal point to then put the means that they are either false or true characters which are the singular

37
00:03:29,400 --> 00:03:32,630
characters that meet just for this a little bit better.

38
00:03:34,600 --> 00:03:41,410
Now examples of these are such as these an integer value might be the number of the students number

39
00:03:41,410 --> 00:03:45,120
of the students in a class that number is a whole number.

40
00:03:45,190 --> 00:03:47,610
Numbers cannot be 2.8.

41
00:03:47,660 --> 00:03:51,130
That is either three or these two or anything like that.

42
00:03:51,220 --> 00:03:59,650
Flawed values are numbers such as let's say the distance between two houses two point three five kilometers

43
00:03:59,650 --> 00:04:05,020
or Miles if you're using a different system an imperial system.

44
00:04:05,020 --> 00:04:12,010
True or False systems are true or false variables are for situations where something is either happening

45
00:04:12,040 --> 00:04:13,660
or not happening.

46
00:04:13,660 --> 00:04:18,430
For instance your game might be paused or not.

47
00:04:18,430 --> 00:04:21,820
Is either of these two is either true or it is false.

48
00:04:21,990 --> 00:04:32,720
And finally there is a single type like the beginning there a game mean either of you or of your name.

49
00:04:32,730 --> 00:04:37,670
For in my case it would be of any use since your characters.

50
00:04:37,870 --> 00:04:43,390
So now that we have these then actually in all of these comments I can show you how we would end up

51
00:04:43,390 --> 00:04:45,430
printing these values.

52
00:04:45,460 --> 00:04:49,430
Let's get rid of that and I'm going to review that as we go along.

53
00:04:50,290 --> 00:04:52,750
I don't need one.

54
00:04:53,620 --> 00:05:01,060
I should have mentioned that some point died Objective-C is a white space ignoring programming language.

55
00:05:01,060 --> 00:05:05,460
It means whether you have these many lines between them or you don't.

56
00:05:05,470 --> 00:05:07,110
It doesn't make any difference.

57
00:05:07,160 --> 00:05:13,620
Also if you have two sets of code in the same same line as long as there is a semicolon between them

58
00:05:13,840 --> 00:05:15,480
and again it doesn't matter.

59
00:05:15,520 --> 00:05:22,300
Of course it's a good practice to give each of our declarations and each nine or four code its own line

60
00:05:22,300 --> 00:05:24,650
so it becomes a little easier to read them.

61
00:05:25,000 --> 00:05:29,430
And that's a very common practice that almost everyone uses.

62
00:05:29,500 --> 00:05:33,860
So I'm going to get that as well and I'm going to get it off.

63
00:05:34,330 --> 00:05:37,990
So the next important thing is about hope to the prison.

64
00:05:38,000 --> 00:05:41,230
This is essentially how could you print them.

65
00:05:41,470 --> 00:05:43,600
Obviously we can use a slug.

66
00:05:43,610 --> 00:05:47,940
This be the same format that we can go ahead of say and Aslaug.

67
00:05:48,370 --> 00:05:53,190
And that's actually good you know a challenge for you guys if you're new to programming.

68
00:05:53,350 --> 00:05:57,490
What happens if I say and it's like my let's run the

69
00:06:03,150 --> 00:06:08,380
let's wait for application to build and run on we can see the result.

70
00:06:08,540 --> 00:06:16,430
So the moment it builds on long it says hello world which is that line and then it says my eans because

71
00:06:16,640 --> 00:06:23,120
it's like preens everything finds between the two quotations identically whatever it finds.

72
00:06:23,120 --> 00:06:24,530
It prints them in here.

73
00:06:24,590 --> 00:06:32,050
So we somehow have to find a way to convert these values into a text value that can be printed in here.

74
00:06:32,090 --> 00:06:43,910
So to do that I'm going to say my intent or integer value is and then I'm going to say Give me a percent

75
00:06:44,090 --> 00:06:45,740
sign and then I.

76
00:06:46,220 --> 00:06:52,260
This means I'm formatting the code so that an integer is coming up.

77
00:06:52,310 --> 00:06:58,020
So it is going to write this part exactly as it is and then it's going to look for an integer.

78
00:06:58,160 --> 00:07:02,540
When I say calm or might it's not.

79
00:07:02,540 --> 00:07:09,770
This format might seem a little bit odd but this is the only format you have to get use to value types.

80
00:07:09,770 --> 00:07:16,430
Value value types value as many times as you want and you can have more of deeper ones of these.

81
00:07:16,490 --> 00:07:19,160
Print this out and then I'm going explain a little bit more.

82
00:07:23,100 --> 00:07:26,830
So now it says integer value is a.

83
00:07:26,970 --> 00:07:29,940
So it prints this part exactly as it is.

84
00:07:29,940 --> 00:07:39,950
So what ever I had in here let's say I had some random text in Yanar and then a column and then a space.

85
00:07:39,960 --> 00:07:41,710
All of that gets printed.

86
00:07:41,970 --> 00:07:48,660
And then the value gets printed so it says I had some random text in year and then divide you what if

87
00:07:48,660 --> 00:07:55,050
you don't want to have anything you can just drop that by its entirety and say just convert whatever

88
00:07:55,140 --> 00:07:57,620
is coming up which it prints 3.

89
00:07:57,740 --> 00:08:00,360
But it's kind of difficult to read it like this.

90
00:08:00,360 --> 00:08:06,290
That's why I use something like integer is a space.

91
00:08:06,300 --> 00:08:09,990
Why not let's go ahead and write this for a float value.

92
00:08:10,050 --> 00:08:14,000
So it becomes a lot easier.

93
00:08:14,250 --> 00:08:20,540
And then in here is percentage f and I'm going to say my float.

94
00:08:20,670 --> 00:08:24,910
Now now you should have kind of gotten a sense of.

95
00:08:24,990 --> 00:08:32,940
So there is a variable in here and that variable is containing a certain value and I'm using that variable

96
00:08:32,940 --> 00:08:33,710
in here.

97
00:08:33,720 --> 00:08:40,440
So instead of typing three point three Yeah I'm typing the name of the variable that holds on to that

98
00:08:40,440 --> 00:08:41,120
value.

99
00:08:41,370 --> 00:08:48,750
And if you print this now you will get to see where integer is three float is three point three.

100
00:08:48,750 --> 00:08:53,120
Like I said you can have multiple entries into one single slot.

101
00:08:53,130 --> 00:09:03,360
So I would essentially go ahead and say I saw an end here I would say the end is percentage this space

102
00:09:03,570 --> 00:09:11,010
and float is Karlo percentage as close quotations.

103
00:09:11,070 --> 00:09:14,720
And now it's expecting two values to show up.

104
00:09:14,760 --> 00:09:17,790
So I'm going to say come on my integer.

105
00:09:17,790 --> 00:09:23,770
So that's the first one for the integer and then this is the second one for float.

106
00:09:24,090 --> 00:09:32,590
So see two entries and two formatting essentially on two variables that correspond to these two types.

107
00:09:32,640 --> 00:09:34,670
If I print that now if it.

108
00:09:34,740 --> 00:09:38,080
Oh I forgot the semicolon at the end of here of course.

109
00:09:38,100 --> 00:09:45,990
So if he been down right now it says in these 3 and throw is something else you might get.

110
00:09:45,990 --> 00:09:51,230
You will get two warnings in here and you had more of those saying on use than ever.

111
00:09:51,270 --> 00:09:56,370
Because this variable has been declared but has never been used anywhere.

112
00:09:56,370 --> 00:10:03,680
And just one important definition that they should talk about declaration and definition and use rates.

113
00:10:03,690 --> 00:10:11,560
Now this line it says declare an integer card and defining it to be three.

114
00:10:11,580 --> 00:10:13,630
And here it's being used.

115
00:10:13,650 --> 00:10:15,270
Let me do another one.

116
00:10:15,330 --> 00:10:21,080
I'm going to say in my other in one when I close the semicon.

117
00:10:21,090 --> 00:10:25,710
So this is called a declaration declaration.

118
00:10:25,710 --> 00:10:32,690
It's means there is an integer called my other end but it doesn't know what is the value in it.

119
00:10:32,850 --> 00:10:40,250
So I could come in here and say my other hand is five and this is what we call it definition.

120
00:10:40,260 --> 00:10:45,640
It says Well the guy that we know that exist it's got a value of five.

121
00:10:45,720 --> 00:10:48,010
So declared and defined.

122
00:10:48,210 --> 00:10:51,150
All you could do both of them in the same goal.

123
00:10:51,180 --> 00:10:57,800
This is a very common practice and we'll see more and more and more of this in the in the coming sense.

124
00:10:57,810 --> 00:10:59,500
So let me drop out.

125
00:10:59,510 --> 00:11:02,350
I actually don't need that in a slide at the very top either.

126
00:11:02,570 --> 00:11:09,540
So I only need these four lines integer float Paulian and kiter and so forth you managed to print two

127
00:11:09,540 --> 00:11:18,060
of them and once two of them together I'm also going two planes and Aslaug and I'm going to say my Or

128
00:11:18,210 --> 00:11:20,430
just a single card.

129
00:11:20,660 --> 00:11:25,870
Years is under this percentage see what I'm going to say my time.

130
00:11:28,950 --> 00:11:30,940
The moment I will run it.

131
00:11:30,960 --> 00:11:33,640
It says count their ears See.

132
00:11:34,050 --> 00:11:39,900
You could of course print the boolean value but that doesn't really make much sense when we use boolean

133
00:11:39,900 --> 00:11:40,400
values.

134
00:11:40,410 --> 00:11:48,350
We usually compare them to a state we say if this boolean is to do something or the other thing I'm

135
00:11:48,720 --> 00:11:49,800
going to write that.

136
00:11:49,860 --> 00:11:53,080
And it's like the board is.

137
00:11:53,120 --> 00:11:55,880
And those are going to be H.H. D.

138
00:11:56,010 --> 00:11:59,300
And don't worry about the very complicated for of it.

139
00:11:59,310 --> 00:12:00,860
I will explain it in a bit.

140
00:12:00,970 --> 00:12:03,820
And there's going to be my in value.

141
00:12:04,230 --> 00:12:07,660
If you printed it should say is 1.

142
00:12:07,680 --> 00:12:08,440
Is it true.

143
00:12:08,460 --> 00:12:15,700
Yes it should say pool is one to get a better understanding of all of these different format things.

144
00:12:15,700 --> 00:12:23,940
I have been through the link with this lesson which is essentially here is string for the specifications

145
00:12:24,380 --> 00:12:25,980
in Objective-C.

146
00:12:26,120 --> 00:12:32,400
I having at this link for you guys that explains what each of these values are and what do each of them

147
00:12:32,400 --> 00:12:34,670
actually actually mean.

148
00:12:34,680 --> 00:12:37,230
How do you convert from one to another.

149
00:12:37,230 --> 00:12:40,400
My suggestion is that you don't try to memorize this.

150
00:12:40,410 --> 00:12:46,220
Just keep this thing handy so whenever you need one you can just go in here and get a sense of what

151
00:12:46,350 --> 00:12:49,530
they do to combat this particular type.

152
00:12:49,530 --> 00:12:57,200
Let's say you have a double and you want it to convert it into a string or let's say you're hard on

153
00:12:57,300 --> 00:13:04,140
unsigned target with integer and you wanted to convert it or if you had a floating value like the one

154
00:13:04,140 --> 00:13:05,690
that we had right now.

155
00:13:05,820 --> 00:13:07,050
So on and so forth.

156
00:13:07,080 --> 00:13:10,620
All of them are somewhere in this link and you can have a look.

157
00:13:10,650 --> 00:13:13,830
I personally don't know more than a few of these.

158
00:13:13,840 --> 00:13:19,040
Whenever I need the more advanced the odds are just coming here I will look for the one I need.

159
00:13:19,140 --> 00:13:21,110
I use it from here.

160
00:13:21,120 --> 00:13:28,860
So with that in mind this is a basic introduction to different valuable types the very basic primitive

161
00:13:28,860 --> 00:13:30,570
variable types.

162
00:13:30,600 --> 00:13:32,120
Let's move on to our next lesson.
