Hi, Alex here from rebeloper.com and welcome back to this tutorial series on
extensions and today we are going to continue from our previous video where
we created a double extension of creating some unit changing from
kilometers to miles. So without further ado let's jump right into it.
So let me just show you where we left off and again if you don't know where to find
the starter project you just simply need to click the link down below and you
will be taken there or just take a look at the first video on this series.
So here we have type in distance in kilometers in the file type in one you
have all of this along with number where the double is presented as its hold.
But we don't want to type present this. We want it to be rounded. Now one thing that
we could use here is add in here to be rounded like dot and rounded okay and
let's see what happens now because we have this is a basic double extension
property. So let's type in here 1 and what that doesn't seem to work, okey.
Now let us just dive into the extension and if you can recall we have created the
measurement, convert measurement here and we have here a rounded to places. Now the
places is how much we want to round to like two, three, four and so on what we
want to add in here and I'm just going to paste all of that in here because I
don't want to have typos we have a divisor and yeah it's kind of a
complicated you don't really need to know how this works just go ahead and
take a look at the code if you want and just use it. So let's go back and
let's just scroll all the way down and here we have our distance convert.
So what we want to do here is add a dot and type in around it to and let's say we
want to round it to 5, okay. Let's build and run and see how all of that
goes, okay. Let's type in one kilometer and as you can see we have 5 here but
to be honest we would rather have only one or something like that 2 or 3.
So let's take a look at that again in action
and that will be it for today. So let us just add in here 0.6 miles well it is
not a perfect but in some cases you want to display only and this. Now again these
unique unit length can be of various sizes and let me just jump to this
definition you can have a megameters, hectare meters, meters, decimeter
centimeters and so on inches, feet, yards, miles furlongs whatever it had might
be and so on. Okay! That is it for this tutorial. Hope you enjoyed it now in the
next one we are going to take a look at a dictionary extension more what I will
not give away what we are going to talk about go ahead and take a look at the
next video that I am going to release. So if you did like this one go ahead and
give it a thumbs up, subscribe to the channel and hit that notification bell
to get notified when I upload the video about the dictionaries. So I will see you
in the next one.