In this system you're going to talk about a very powerful you know tool in swift that is called God.
God is essentially a way for us to validate information validate is specifically optional informational
optional attributes or variables.
So let's go ahead and do that in school and then it's called and start a new project my new project
I'm going to call it Gordon it is swift.
Now imagine a situation like this.
Imagine you have than me take those out and have an optional one which is a string optional.
But it does have a value for instance.
And then I have these three times I have optional two and I have optional three.
And then my optional to says hello vor the optional says of Vios.
So I have three values but they are all options and I cannot be sure if they actually have a value in
them or not.
So the current way of doing it what you already know is doing this saying if that lets up one that's
being optional one.
Now imagine this a situation that they needed all three of them to be correct.
So I'm going to have to say well if that was the case and if left up to to become my optional too and
if that was the case one if let's of tree be my optional tree of course.
And even that was valid as well.
I don't know let's say print printed this pranged
and then let's concatenate all of them together.
All right let's concatenate them with the spaces so hello world of us it would be up 1 of.
And not like that up to up to 3.
All right.
And there's really nothing wrong with doing it this is just that it's a very it's a very messy way of
writing things you know and trying to have an error in here as well.
Yes.
So it's a very messy way of writing things essentially having so many you know nested if statements
that they all work together and then it kind of makes things quite quite messy.
So an alternative for this situation is something called God.
So I'm going to say God is my God I'm going to say these are the things I want to god let's all one
not be optional one and you can choose the type of faith for instance as a string.
You know I'm going to say I want to know if it is this thing or not and then I'm going to have to say
and another god
and two and three and then this is going to be my two and this is going to be my tree.
So when they got these two.
All right.
Otherwise do something else otherwise decide about you know are removing them or deleting them or anything
of the sort.
So what's happening is this I'm saying well there is something called up one which is optional one as
a string.
If that thing exists guard it and then got up to and then got up to the.
And then if all three of them are working come here to this line you know do whatever you have to do
is do something right through this thing that we wanted to do.
Preens all of these values are there voice.
You have to go out now going out or doing your return.
It means that we have to somehow be within a body of a function or a for loop or something of that sort.
So I'm actually going to put everything inside a function and then I say my God and My God essentially
does this.
All right.
Let me read them to rethink that me clean all the code and only go with the things we absolutely need.
So they begin making more sense.
All right.
So I have two optional values.
All right my three optional values and guarding them by the time.
Right.
And I'm saying if that wasn't the case just return otherwise do that.
So you're saying that having a set of myths that you feel statements or if statements that each of them
depends on the previous one and the previous one the previous one and guarding as many values that I
want and then if they are all OK then I get to here to do whatever I want to do.
If one of them fails I just retire.
So this is very useful for situations where the life of several variables depends on each other.
If you're read information from a network and every bit of information must be there before you can
present it or anything of that nature in the next lesson or we're going to actually use this god for
reading information into something called a convenience in its art.
This thing here the warning don't worry about it simply because it is saying that the value you are
trying to convert is of the type of string.
So definitely this we always succeed.
But in real life scenarios we usually don't read or optionals from value but that we know what they
are we might be reading them from things that we're not sure what kind of nature they have.
So based on that let's keep it up to here and we'll move on to our next lesson.