In this lesson we're going to talk about the variables.
Everybody is essentially a container for a value.
And since the name suggests it's a very wrong value that can be entered into that valuable variables
are used to store different information and presented to us whenever we need them.
But before we go that deep into understanding the role of variables in our programming language.
Let's get a sense of some of the basic facts and then from there on we can one more advanced topics.
So let me jump back into school and it makes for then I'm actually going to close this project and to
start a new one.
So file new project just like the last time I'm going to use.
My question I'm going to use the command line tool.
I'm going to call this long variable's project not in my variables project just like the last time I'm
going to go to my dad and find him remove all the comments so that the code is a little bit easier to
see and then get rid of this part of it.
I like my presentation.
I'm going to talk about four types of variables.
Integers floats characters and what happens.
So let's see what all these things so well we'll write that integers floats booleans and of course characters
or characters.
So let's see what they are.
The first one is let's call it in and I'm going to call it my ends.
Equals three for instance.
Then I will write another one.
And when I say floats and this one is going to be my float and that's going to be to point three and
then I have another one card for my boolean and that is currently true.
And then I have a cat there.
Or my cat is the leader I see.
So by just looking at them you can kind of get a sense of what they are.
Integers are the whole numbers so whole numbers between if I can get the sign of infinity in
infinity Yes I won.
So between negative infinity and positive infinity and then float values are numbers with decimals.
So such as three point three essentially any integer is also a float value as well.
So this is essentially three point zero you could have twenty point zero in here.
Boolean values are true or false or yes or no.
So a sort of true I could use the yes I'm more used to using true because that makes more sense to me.
And characters are essentially singular characters so integers all numbers float values that they have
a decimal point to then put the means that they are either false or true characters which are the singular
characters that meet just for this a little bit better.
Now examples of these are such as these an integer value might be the number of the students number
of the students in a class that number is a whole number.
Numbers cannot be 2.8.
That is either three or these two or anything like that.
Flawed values are numbers such as let's say the distance between two houses two point three five kilometers
or Miles if you're using a different system an imperial system.
True or False systems are true or false variables are for situations where something is either happening
or not happening.
For instance your game might be paused or not.
Is either of these two is either true or it is false.
And finally there is a single type like the beginning there a game mean either of you or of your name.
For in my case it would be of any use since your characters.
So now that we have these then actually in all of these comments I can show you how we would end up
printing these values.
Let's get rid of that and I'm going to review that as we go along.
I don't need one.
I should have mentioned that some point died Objective-C is a white space ignoring programming language.
It means whether you have these many lines between them or you don't.
It doesn't make any difference.
Also if you have two sets of code in the same same line as long as there is a semicolon between them
and again it doesn't matter.
Of course it's a good practice to give each of our declarations and each nine or four code its own line
so it becomes a little easier to read them.
And that's a very common practice that almost everyone uses.
So I'm going to get that as well and I'm going to get it off.
So the next important thing is about hope to the prison.
This is essentially how could you print them.
Obviously we can use a slug.
This be the same format that we can go ahead of say and Aslaug.
And that's actually good you know a challenge for you guys if you're new to programming.
What happens if I say and it's like my let's run the
let's wait for application to build and run on we can see the result.
So the moment it builds on long it says hello world which is that line and then it says my eans because
it's like preens everything finds between the two quotations identically whatever it finds.
It prints them in here.
So we somehow have to find a way to convert these values into a text value that can be printed in here.
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
sign and then I.
This means I'm formatting the code so that an integer is coming up.
So it is going to write this part exactly as it is and then it's going to look for an integer.
When I say calm or might it's not.
This format might seem a little bit odd but this is the only format you have to get use to value types.
Value value types value as many times as you want and you can have more of deeper ones of these.
Print this out and then I'm going explain a little bit more.
So now it says integer value is a.
So it prints this part exactly as it is.
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.
All of that gets printed.
And then the value gets printed so it says I had some random text in year and then divide you what if
you don't want to have anything you can just drop that by its entirety and say just convert whatever
is coming up which it prints 3.
But it's kind of difficult to read it like this.
That's why I use something like integer is a space.
Why not let's go ahead and write this for a float value.
So it becomes a lot easier.
And then in here is percentage f and I'm going to say my float.
Now now you should have kind of gotten a sense of.
So there is a variable in here and that variable is containing a certain value and I'm using that variable
in here.
So instead of typing three point three Yeah I'm typing the name of the variable that holds on to that
value.
And if you print this now you will get to see where integer is three float is three point three.
Like I said you can have multiple entries into one single slot.
So I would essentially go ahead and say I saw an end here I would say the end is percentage this space
and float is Karlo percentage as close quotations.
And now it's expecting two values to show up.
So I'm going to say come on my integer.
So that's the first one for the integer and then this is the second one for float.
So see two entries and two formatting essentially on two variables that correspond to these two types.
If I print that now if it.
Oh I forgot the semicolon at the end of here of course.
So if he been down right now it says in these 3 and throw is something else you might get.
You will get two warnings in here and you had more of those saying on use than ever.
Because this variable has been declared but has never been used anywhere.
And just one important definition that they should talk about declaration and definition and use rates.
Now this line it says declare an integer card and defining it to be three.
And here it's being used.
Let me do another one.
I'm going to say in my other in one when I close the semicon.
So this is called a declaration declaration.
It's means there is an integer called my other end but it doesn't know what is the value in it.
So I could come in here and say my other hand is five and this is what we call it definition.
It says Well the guy that we know that exist it's got a value of five.
So declared and defined.
All you could do both of them in the same goal.
This is a very common practice and we'll see more and more and more of this in the in the coming sense.
So let me drop out.
I actually don't need that in a slide at the very top either.
So I only need these four lines integer float Paulian and kiter and so forth you managed to print two
of them and once two of them together I'm also going two planes and Aslaug and I'm going to say my Or
just a single card.
Years is under this percentage see what I'm going to say my time.
The moment I will run it.
It says count their ears See.
You could of course print the boolean value but that doesn't really make much sense when we use boolean
values.
We usually compare them to a state we say if this boolean is to do something or the other thing I'm
going to write that.
And it's like the board is.
And those are going to be H.H. D.
And don't worry about the very complicated for of it.
I will explain it in a bit.
And there's going to be my in value.
If you printed it should say is 1.
Is it true.
Yes it should say pool is one to get a better understanding of all of these different format things.
I have been through the link with this lesson which is essentially here is string for the specifications
in Objective-C.
I having at this link for you guys that explains what each of these values are and what do each of them
actually actually mean.
How do you convert from one to another.
My suggestion is that you don't try to memorize this.
Just keep this thing handy so whenever you need one you can just go in here and get a sense of what
they do to combat this particular type.
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
unsigned target with integer and you wanted to convert it or if you had a floating value like the one
that we had right now.
So on and so forth.
All of them are somewhere in this link and you can have a look.
I personally don't know more than a few of these.
Whenever I need the more advanced the odds are just coming here I will look for the one I need.
I use it from here.
So with that in mind this is a basic introduction to different valuable types the very basic primitive
variable types.
Let's move on to our next lesson.