Welcome again in his lecture, I'm going to show you why do you need to use a hota and what is that?
Let's start.
They say that you want to declare constants that represent the days of the week.
This way you will prevent the magic numbers in your code, right?
So each day will be represented with a unique number.
To do that, you need to initialize the constants with increasing numbers for each day or they will
clash.
First, let's to declare a few constants for the week, this.
The first one is Monday, and its value is zero.
Second one is Tuesday and its value is one.
As you can see, I am increasing the numbers one by one for each constant.
And it goes like this until Sunday.
OK, now let's bring the.
OK, let's try it.
This prints the numbers from zero to six, as expected, because I know about the features I've got,
typing it like this looks unnecessary to me in a second.
You will also think the same thing.
It's because God can do this for you.
Let's check it out.
As you can see, I removed the constant value.
Now you're going to learn how to use the IETA, the number generator for constants.
Let's initialize the first constant with Ayata now.
OK, let's run it.
As you can see, it prints the same output just like the previous example.
So how does this work?
Is it magic?
Yes, it's magic, it uses the following features of go first constants, repeat the previous constants,
type an expression, second ayata the number generator for constants.
As I said, IETA is a number generator for constants.
Think of it like an ever increasing automatic counter.
For each new constant here, I will generate a new number automatically because each constant will repeat
iota as its initial value, as if they're being initialized with IETA.
So I will keep increasing itself on this while it becomes zero, because it starts at zero.
And Tuesday becomes one because Gore increases the Ayata for each constant and Wednesday becomes two,
Ayata keeps increasing, Thursday becomes three, Friday becomes for, Saturday becomes five, and lastly,
Sunday becomes six.
And after the multiple constant declaration and Gore sets Diatta.
So if you use it, it's another constant declaration.
It will start from zero again.
As you can see here, IETA keeps increasing automatically for each constant.
So behind the scenes constant repeat ieta.
This happens because a constant repeat the type and the expression of the previous constant.
Let's take a look at another example.
It's you know, you can use expressions, initializing consonants, since IETA is actually a value,
so you can use it in a constant expression as well.
Let's check it out.
As an example, let's add one to IETA initializing the Monday.
Now, this expression just adds one to iota and generates a new value before assigning it to the Monday
constant.
So what do you think about this?
I mean, what values these concerns we will get when I run this post video?
Now, think about this for a minute or so, then continue.
OK, let's turn it now and find out.
As you can see this time, the result is different.
Instead of starting from zero, Monday has started from one and others have followed it.
Now let's see how it works.
At first, IETA starts at zero, but the expression is Ayata plus one.
So Monday becomes vom instead of zero and Tuesday repeats the previous expression and it becomes too
two because Ayata is vonne, but the expression is ieta plus one iota becomes too and Wednesday becomes
three.
After that IETA becomes three and Thursday becomes for next Ayata becomes four and Friday becomes five.
An iota becomes five and Saturday becomes six, unless the ayata becomes six and someday becomes seven.
As you can see, each constant repeats the mon's expression, so each constant repeats ieta plus one
expression using an expression that depends on your imagination.
It can be very powerful for ideas.
Please check out my blog post about IETA.
It contains a lot of tips and tricks.
I attached the link in resources for it.
Now let's take a look at how to use the blank identifier with Iota.
Remember, the blank identifier is like a black hole which eats values without any point of return.
Let's take it out.
They say that you want to declare constants for representing a few common time zones.
Let me show you the time zones table.
First is the here means Eastern Standard Time.
It is five hours behind of UTC, by the way.
UTC means universal time.
And Misty is Mountain Standard Time, and it is seven hours behind of you to see unless the city is
California standard time and it's eight hours behind of UTC.
So according to this table, how should I declare Constance?
Let me show you.
Let's first declare Constance using a multiple constant declaration.
I'm going to declare three constants, which will represent the time zones according to the table,
they should be minus five and they should be minus seven and they should be minus eight.
So let's declare a constant for E as minus five.
Domestically and other concerns for amnesty, it should be mine seven.
And lastly, let's declare you should be minus eight.
OK, great, now print those constants.
OK, listen, it's.
OK, now let's suppose that the actual time zone table is much more longer.
If so, then it's better to use IETA.
But how can I do that?
This figured out next.
No, I removed the initial values from the constants, that's because I want it replaced, I'm using
Gouta.
In the meantime, I calculate with a formula or actually I stole it from one of the examples I striated
Ioanna.
Now, four of the boxes next to the Constance, I'm going to display what my formula competes for each
constant.
So according to my formula, E will be minus five.
Creates my formula works.
Let's look at Misti constant now.
According to the Time Zones table, it should be minus seven.
Let's check it out.
It looks like my formula has calculated it as minus six, but it should be minus seven.
Bomber, some formula doesn't work.
Let's continue for now.
Let's look at the constant this time.
Is incorrect as well, my formula returns minus seven is minus eight on the table.
So my formula definitely doesn't work.
OK, let's run it.
Compare the output to the time zones table, you'll see that the program's output slips minus one hour.
So to solve this problem right on this line between Estey and Misty, I need to increase Ayata without
declaring another Konstanty, right.
So if I do that, then the constants will match to the time zones table.
Let's do that now.
Now, I moved Misty and Constance Van Line down.
Now I'm going to add a blanket and fire right between the east and the misty constants like this.
This recalculate the value again.
Let's start with S-T.
I vote is zero now, so if I put iota into my formula, it becomes five plus zero, which is five and
one multiplied by minus one is C becomes minus five.
Now, cool is correct so far.
Now, let's take a look at the next line.
I will keep increasing here.
So the formula looks like this five plus one multiplied by minus one is minus six.
This value will be assigned to the black identifier.
Remember, the blank identifier is like a black hole, but to send into it will disappear.
OK, now let's take a look at Mauti.
Five plus two multiplied by minus one is minus seven, good, according to the Times on Seybold is also
correct.
And lastly, take a look at the five plus three multiplied by minus one is minus eight.
So this is also correct.
As you can see, by using a blank identifier, I can adjust the values of the constants correctly.
I use the blank identifier only for increasing Diatta, and I didn't use it ever after.
So you can use a blank identifier an iota to adjust the values of your constants to perfect.
All right.
That's all for now.
Thank you for your patience.
See you in the next lecture.