Kotlin Programming Language from A - Z : CHAPTER 1 - Fundamentals of Kotlin | Kapil Bhattarai | Skillshare

Kotlin Programming Language from A - Z : CHAPTER 1 - Fundamentals of Kotlin

Kapil Bhattarai, Mobile and Backend Developer

Kotlin Programming Language from A - Z : CHAPTER 1 - Fundamentals of Kotlin

Kapil Bhattarai, Mobile and Backend Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
29 Lessons (2h 8m)
    • 1. 1. Installing java jdk on windows

      2:30
    • 2. 2. Installing Intellij idea on Windows

      1:11
    • 3. 3. Installing java jdk in mac os with Java HOME

      4:38
    • 4. 4. Installing Intelllij Idea on Mac OS

      2:15
    • 5. 5. Hello World Program in Kotlin

      3:01
    • 6. 6. How to declare variable in kotlin

      4:14
    • 7. 7. Difference between val and var keyword

      3:19
    • 8. 8. Architecture of Kotlin

      1:50
    • 9. 9. Primitive Data Types in Kotlin

      4:03
    • 10. 10. Functions in Kotlin

      11:40
    • 11. 11. String interpolation in kotlin

      3:00
    • 12. 12. Null Safety in Kotlin

      3:55
    • 13. 13. Making our program null pointer exception free

      8:09
    • 14. 14. Late initialization and lazy initialization in kotlin new

      13:10
    • 15. 15. No Automatic conversion

      1:17
    • 16. 16. If else in kotlin

      3:57
    • 17. 17. Input Output in Kotlin

      3:01
    • 18. 18. When as a Statement

      2:46
    • 19. 19. When as a Expression

      1:36
    • 20. 20. Calling Kotlin Function from java and vice vera

      3:49
    • 21. 21. String operation in kotlin

      13:10
    • 22. 22. For Loop

      2:07
    • 23. 23. While and Do While Loop

      1:59
    • 24. 24. Ranges in Kotlin

      2:00
    • 25. 25. Break Continue and Labels in Kotlin

      5:01
    • 26. 26. Extension Function

      5:12
    • 27. 27. Infix function in kotlin

      2:57
    • 28. 28. Function overloading in Kotlin

      3:10
    • 29. 29. Tailrec function in kotlin

      8:39
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

82

Students

--

Projects

About This Class

This class is a part of programming series called Kotlin Programming Language from A - Z . The whole series covers every aspect of Kotlin Programming Language. The course is designed in such a way that even a absolute beginner in programming field can grasp the knowledge about Kotlin.

836aa4d2

In this class, we learn about the fundamentals of Kotlin Programming Language. After the class, you will be able to play around with Kotlin and understand its basic rules and syntax.

Let's Learn Kotlin.

01dea25e


If you have any confusion about the class lecture, feel free to ask on comments. I am always there to you help :)


- Kapil Bhattarai

Meet Your Teacher

Teacher Profile Image

Kapil Bhattarai

Mobile and Backend Developer

Teacher

Hi, I am kapil. I love learning new skills and teaching. I am mainly interested in Programming, Humanity and Astronomy. I have many years of experience in mobile development as well as in-depth knowledge of back end web development.  My passion is helping people to find their hidden talents through online teaching and show the path towards their goals.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. 1. Installing java jdk on windows : in this lecture, we're going to install the job by now missing in order to check whether you're missing heads our not go to the windows and type command and open up the common room and just died Java Sea. If you got to messes like Jabba is not recognised internal or external command, then there is no job on your machine. Now go to the Google and type Jabba Jay Dickey don't load. And one of the first link that is of Oracle and go to the download six in and click on Oracle Jet Digital Mood. If you school a bit, you will see a list like this this click on the except lies in agreement and depending upon the operating system and debit card A to Z respect you often I'm using the windows with the 64 bit, so I'm going to download energetically Window 64 on the school. Been dirty XY so broken down. Good if you don't know your operating system But it didn't go to the computer and red click on the this PC and go to the properties And when When his windows with operating system 64 bit and I'm gonna pour this for you until our download is finished. Onda Hazel Job Agility. So let me double fugue on that Clegg Next and leave everything as default and Blake Next and Heavy have installed out over. So let me close that. Let's go over the my computer and go to see Go to program files and then you will see the fold. Recall Jabba, let's go inside the bin and we need this Files were copied this and let's goto this p she and go to properties and go to the advanced system sittings. Click on the environment very well and go to the system variables and in the bath and click on it and no click on the new and copy that part in here. Okay, So, big cookie on who? Jokey and hit. Ok, once again. Now go to the Common Prompt and DYP job a C Precede the instruction like this then congratulations, rabbis install on your machine If you have any problem during the installation, then do let me know in the comment on DSI even the next part 2. 2. Installing Intellij idea on Windows : hello, everyone in this episode working to download the intel ity idea for our coding environment . So first will go to the Google Garcon and type until is a I d download and click on the first link off jetbrains. You will see this Pace picante download the community person. It's a free and open source and it will get our job done. So no need to go for the ultimate one. So this quick download and our downloaded started, So I'm gonna post this video until the dollar is finished. And here's our dollar. So whatever. Click on that. Hey, drunk and click next next, like next and hit Install. So it's a really large software and it might take time. And here is our software. It took me around two or three minutes to get install. Anyway, just click on this around office and on head finished, and at first you were going to see this screen like this 3. 3. Installing java jdk in mac os with Java HOME: Hello there. So let's install double digit again our Mac operating system. So for the rationally to open the terminal, click on this source Aiken or click Command post space and then type terminal. Let me increase the phone size and just drive daba and hate Inter. And it says, no job a runtime prison requesting install. And if you go to more info and then if you get a cost to the this dollar piece are you can go to Google and type Jarba Judy Key and you will see the Oracle based That's creaking that and go to Donald sits on so they can see this to our same place. So let me close one of this and you just need to click on this download button except license settlement. I'm running Mac operating system here, so I'm gonna download this a DMG file. So click on this link and my downloaded started, so it's a las file. So let me pause this video So once you're dollars complete Goto Dollar folder and Harry can see your DMG file, so double click on that on is we're going to open up the Pakis, so just double click on that as well on our installation without opens up. So just sit, continue instrumental and those interview country password and or java dedicates install so hit close. And here you can actually move this dedicate to the crest. So let's move this to the press. I know. Come to the terminal. First of all, just close this time now and open a new terminal from here. So let me increases fund and just trip Java. Does Gordon and you can see we have installed is Arba are for Isn't the weapon open to And no, we need to configure Zappa home in our computer on in order, see whether your computer hides Alba homes that up or not to strike equal on, then dollar and type in Juba underscored home. And if you see empty, then there is no double home set in your computer. And in order to save the job a home, you need to come to the root directly. And as you can see, I'm already in the root directory. And if you're not sure whether you are in a row directly or not, the Step CD and then till command and then hit enter and now you're in the root directly. So let me show you some file share. So if I type jealous gas A And here you can see we have some normal full dress as well as some hidden folders for example dot bass history, not basses. Um, and we need to place our job home Hebel into the best profile. But you can see there is no folder called Bass Profile. So let's first create that folder. The step, touch and deal command. Then for worst less. Dr. Bass on the score profile and hit Enter. No, If I do ls on my list e then you can see we have that folder called Best on the School Profile. Now let's open this best undiscovered file for that. Just type open minus e on. Then Dalton, best on the school profile and hit enter and our best profile opens up. And here you need to type exactly what I'm typing. Alright, Export java underscore home. It's cost toe, so make sure there is no a space in between them. Otherwise it will not gonna work. And then it's less you as a user and then leave. He actually left acute stress on Java. Underscore whom? Unclos the bracket and go and save this file file and save. And you cannot close this and I suggest you to close this storm will as well Andrea pawn this terminal And here if we drive Ekho dollar Java from the school home and you can see we have success with the set of the home part in our Mac operating system. 4. 4. Installing Intelllij Idea on Mac OS: Hello there. So on the surface where we're going to install the Antilles et for our coding environment. So first, awful go to the Google and type Intel is a I D and download, and you will see a website called that Prince Car com and click on this link. And here you can see to download apps an ultimate one and community one. And since we're just learning and are all of those stocks can be done with this comedy Borssen. So we're going to download the community one on Herrick and see the different platforms. So I'm running Mac OS. There's, um I'm going to stick the Makris. If they're running Linux, then go for leaners. And if you're running the windows, go for Windows one. Okay, so for now, let me click on this down the bottom and my downloads had started. So this is a large file. I'm gonna pause this video. All right, So once you download is complete, go to your dollar folder and you should see your DMG file, So just double click on that on it were going to verify and just tracked these I d to your application failure. Andare said you're intelligent, I d installing your or Mac opening system. So let's open up that. So open every sport light and type until his i d and just open your i d From there on your operating system will going to prompt a mess is just split open. Click Don't enforce sitting and click. OK, you can that checkbooks and hit Continue. Okay, so if you want to send the uses, start us do that for now. I'm not going to do that. Don't send. So I'm gonna choose the track lone andi for restaurant things. I'm just gonna skip remaining and said if all OK, so it's click on that and your i d intel is a will. Open up and you should see this box. And from the next episode, we're going to write the code on this I d. So 70 next episode 5. 5. Hello World Program in Kotlin: Hello there. So only suppose you're wanting to create our force. Hello, World program. So, first quality, Candace creating new project and you can actually cancel them here can actually toothy job and then selected jbm and click next. Oh, you can actually go to the chortling and Cedric the court. Linds lesson gbm from here. Put up them are same. So let me go and click the next button. And here Unity specified the project name. Let's especially the our program as learning Courtland, let me choose the directory and let me create a folder called Katelyn on Let me open up That and our Lucas and will be in here and here I was about to release, selected his accordance. Our runtime came from the integrity I d by default. So let's it finished. And here is your false cotton project. And if we expand this chortling Pakis here you can see another packets called SRC, and here we're actually going to write all of our files. So we're kicking that andan Tuesday chortling while class and here unity actually give the name. So let's keep our name as hello world dot Katie and pay special attention in here and for every court in for all its extension will be dark. Katie. Okay, so slick. Okay, here and here are just right here. Free and phone. It is transfer function, and then right main on open the curly bracket here and in here is this right Print, Ellen. And then hello, World already can run this program. That's by clicking with this green button. Or just go to this our own upson and then click run in here. So sago chortling file and in your consulate can see our Hala Wallace there. And before signing off from this video, let me go to the preference. And if you're running the windows, then go to the violent and sittings and in appearance, you can actually switch your team. If we like the black team, then you can go for it. So for now, I'm just going to, to his delight one because off recording purpose. And if you go to the editor on Goto General and if you look at the auto import option and makes you have these two state parks electric and these two bottles will help us to ultimately import all of those classes in the around time. So are intelligent. I d will ultimately going to import them for us. Andi, Me go to the phone tops, and here you can actually change the phone taps. And if you want, So let me make it 15 for recording purposefully on. Just Okay. All right. So this is it, and I will see even the next part. 6. 6. How to declare variable in kotlin: hello and welcome. In this episode, we're going to talk about the different metals that we can use to declare the valuables. So before that, I'm going to show you one very, very important thing here. So if I hover on this Tammy Kahlan, it say's redundant semi colons that means by default are chortling already. Place the semicolon at the end of each statement. So we don't need to write that that medium of that. So this is one of the important difference between chortling hand java. Now let's move toward Put is discussing. So, you know, to declare the variables there are a couple of metals. The false metal is illiterate VL val and then name off your variable. So lets him I want to name my very blessed fruit on. This is a type of a string. Okay, And let's assign this value as apple. And don't worry about this crumb string, Val, and why I'm placing the apple inside the court isn't on all that. Okay, so the follow me as of now and I will make you clear as we go on now, I will show you the second matter on in this matter unit I ve air vire and them name off their variable. So let's say I'm gonna name I variable as game and this is the type of a string this time as well. On Let's Assign This variable has football. And don't worry about this difference between the keyboard Val and their on going talk about this to keep bowls after this video on the tormentor. Brooklyn, the very valleys. Very straightforward. This to VFR. Then you need to read the name of for variable again. So let's say I'm gonna name this variable as a person and you just need to assign the value to this variable. So let's say, Sam, one important thing is here. I'm not excellent specifying the data type. Here are data type. We're gonna be automatically assigned based on the teeter innocents and are variable insulation here. I'm actually assigning this very well. Look with cortisone. So our person very well is automatically spring and you can operate this metal for value. Also in Violet's person. One on. Let's see joy and let me so you want feet meter. In this case, you can do something like fell and then name off the variable, so Let's see our name of the baby will be car and then ride the colon and then I d data time and later you can actually assign your variable name in the program at the wrong time . So let's say moral us, OK, you can also to the backyard for this kind of approach as well. So this is gonna be tried spring on later. I can still sign as moral X. So these are the methods that you can use to declare the very ones Now what is the river? So they will just like a box. And you can actually put the data inside that variable. And one primitive, valuable warmly supports one object, and we're going to talk about the area and already stop in the later part where one available can hold lots off lots of data. So let me print these variables here, so print Helen fruit So similarly. Print Ellen Game Print. Ellen Person Cringe, Ellen Barson one her and then car one. Now let's run this program. So there's click on this green button and click that and here you can see we just printed all those variables in our console. So apple for balls. I am joy. More less, more acts on Hello world. So this is the brief introduction about the how you can actually declared the variables in country. And I will see you in the next episode where we're going to talk about the difference between where and Val Keyboard. So Stephen D next part. 7. 7. Difference between val and var keyword: Hello, wonderful people. So on this episode, we're going to talk about the difference between Val and Barkeeper. So in this two variables, I have declared the one variable ads of L and declared the aren't available as of our so in court lean when you define a variable with a VR var keyboard, then it becomes mutable. And what a meaning by is that you can always over the value of that variable whenever you want. So, for example, let me update the value of this variable called game after this Hello world. So let me say game and the cost to cricket. You can see it is not giving us any here. So let me also print this value print Ellen and let's see game. Okay, so it is perfectly fine. But let's see what happens if we try to. It seems the value of a variable which is defined with VL val keyboard. So let me try to since the value of this fruit So in here if I dive because to Horan's it is now giving a serious value cannot be reassigned. So whenever you declare a variable with Rielle Val keeper, then it becomes real only property once you initialize them. So, for example, have already initialized this food valuable with this apple once I instead, as this, it becomes a read only property. So if I try to relate this property, then Kourtney language will not allow us. Now let me take a small moment to talk about the comments in coddling. So let me first remove that now in chortling. If you want to write a single and comment, then unit used to forwards less. And this becomes your single and comment on that can see. Once I commented this very well called fruit, it is giving me the eater. Let's see what it says Own result reference to foot. So let me remove that. Now. If you want to have multilane common, then you need to use it's less and then aspic. And then you need to close the multi and common as gastric on, then forwards. Lest once I do the multilane commenting here it is giving us either in this four variables fruit game person in person one. That's because I have common did these variables here. So let me onto that. Okay, So before signing off this video, I would like. They spent one more concept. Okay, so bear with me. Now let's talk about the print Ellen and print. So if I do print and then write my message here, let's say it's Ah, masses and you know the line did see it's ah, second mess is a nullity. What happens if I around this program here when you actually used the print island than our coarser will go into the next line? But when you use the print function than are coarser will remain in the same line. So, for example, it says it's a mess is on in the same line. It is also printing. There's a second message, but if you look at the other case, every spring is printed in the under the line on. This is all I want to cover in this video, and I will see you in the next episode. 8. 8. Architecture of Kotlin: and this official, we're going to see how are courting file Ron's in our GBM. So if you're from the it's our baloney, you probably know that our every dort in Sabah file it's going border into the dark class file on their door class. Riley's passed to the DBM. So who is also the similar kind of strategy? So, first of all, our door kitty file, he's automatically converted into the God class file and this door past file. He's back from Independent. We are going to pass this guard class file into the DBM, so there so are courting programs fronts on that. Just by looking at this diagram, you can guess that courtly language is not a completely different language. So this is just really find wasn't off our old friend. Now let me absolutely real example. And here is a previous program called Hello World or Katie. Now, if you go through this out packets and into the pore oxen, let's go inside the courting and here you can see the file call Hello World Kitty Dark Glass file. So let's open up this and it says compile cold. So our hello world or Katie file is converted into a hell. A wall, Katie. Door class falling here. And this bite could pass into our Libya. And we only have the tibia because we installed the Zambezi. Ricky. So that's how our whole program ridiculous. Okay, so just for fun, let me actually run this program and his our airport. So behind the scene, this Katie file is converting to the dot class file and this class while it's personal DJ Veum and we're getting our result in our console. So have you understood the basic architecture of courtly in on balance, even d next, but 9. 9. Primitive Data Types in Kotlin: So in this episode we're going to understand the primitive data types and chortling. So this topic is very easy to understand. Imported contains very important concept to writing better program. So how does this actually created the two files? Did I start Katie and data types? Example dot Katie. So in the data types example dot kitty So there is just the main function and nothing else . And in our direct lifeguard kitty have a main function and inside that I have some comments in here. So let's understand the Indies a data types in, courtly in. So if you want tohave extremely large value that reigns between these two numbers, then you need to use the long You cannot actually use thought in teaser bite, you know, to support these long value in that time. Unity use the long hair is one important trade off. If we're going to use long not well, you're going to have the large number of rains, but also your variable. We're going to take a lot off memory. That is, it is going to take the 64 bit compared to and you can see it only takes t 22 bit but in create off, it is only going to support the range between these two and similarly for sorting bite. It is going to take 60 beats for sort and eight bit for bite and their corresponding greens Are this okay now? Similarly, if you want, include the floating point here you need to use the double our float. And if you use floor, then you're going to support this amount of significant disease. And for double, you're going to support this amount of significant dizziness. It is very large, and for character it is going to take the 16 bit and for bullion it is going to take the eight. Okay, so this is just the numbers. Now let me show you how you can actually, if recently use them in your program. So first of all, let me actually declare the variables. So let's declare our long available the step Well, our bar and then name off here long. So let's say and then you you need to assign the values. So let's see. Okay, let me actually copy that and vision here. So this is my long value case. Let me actually remove this much spot. So this is gonna be our long value. So we assigned this value to here. Now we can also do the same thing for other variables as well. So let me quickly do it for you. And this is holding a declared the variables, and I will. So you one interesting pattern here, let me do something like, well, number one and I'm going to assign this variable with a more five. Now, can you guess the detective of this non Very well. Well, you might have guessed the detective will be bite because it is going to take the less memory. And still, the fi belongs to this rains. Well, that is not the case here. So whenever you define the variable without declaring the data dive in case off number, So by default, this variable, we're gonna be in teaser data type. And if you include something big number like this, then by default, it is going to be long. So if you're assigning a number that belongs to indifference, then by default, it is going to be in Pisa. Neither sought nor bite. And if you're assigning the number that belongs too long not in the Indies. Arendse then by default, it is going to be long. Get a tight. So we understood that this is the basic contradiction in chortling. Now, what if in the same example like this five, we want to make this number one as bite are sort Because we know that our number will always going to greens between bite are sort. So in that case, you need to do not to bite are toe sort. All right, so this is how you cannot see the bite and sort here. The data type of this number is gonna be sort. So I hope you honest with the primary data types in Cortland, and I will see even the next part. 10. 10. Functions in Kotlin: Hello there. So let's talk about the functions in court in. So let me create a file call functions dot kitty and let's write our main funds And in here and inside this function, let me type some message here. I'm learning coddling. And in the next lane, I want to print programming language and his er output with says, I'm learning Katelyn programming language. Now let's bring the same message from our costume function, you know, to do so, you can create your own functional itis, united IVF ian phone and the name of your function. So let's say our function name is Masses and opened the courtly bracket and close their Carly bracket. So I'm just gonna caught this and based in here now we need to call this function So here to call this one's in those two messes and then peer of courtly bracket. So let's run this program one more time, and here is your same hot food. So let's pass some data between these functions. So first of all, let me create available called fruit. Let's also in this people as apple and I can simply pass this food inside this function. Now as soon as I do that it is saying too many arguments for public funds and messes. So here you need to define the argument. So our argument we're gonna be fruit, and it's a type of string. Now we can simply print that messes in here so fruit and it can name this valuable anything you want. You don't need to specify exactly the same. For example, I can just say fruit name and here I need to do the same thing. So let's run this program, man. You can see Apple, okay, lets parts multiple values. So that say, another available call Game on. Let's assign this game as cricket and this past, this cricket from here as well, Still game. And we also need to handle the case in here. So game it is gonna be after screen. Let's bring that in here. Okay. So this is how you passed the multiple parameters. You can also directly past the variables like this. So let's see. Four, five. Okay, you can even do like this. And in here, you need to handle them. Similarly, store number one, it is type of in teaser and number two. So this is how you can pass any number off arguments from functions. Now let's make a simple function, which is going to take the first name and surname as a perimeter and going to return the full name as a region type. So for that begins to function on, Let's say full name it is going to take the force name and is going to be of type of string on. It is also going to take the surname, and it's also going to take the diapered this spring. Now we want to return some data from this function and in order region the data from the funks, and we need to specify the region data type and in courtly, and you specify the data type as colon and then name off their data type. So in this case, a string and let's region this data on dollar first name and then so name. And this is how you can return the data from defense. And let's call this function in here. So print Helen and just write the name of her friends and which is full name. So our first parents is the first name. Let's say call and our sir enemies Saigon. Now let's run this program, and here you can see the output. We say it's Carl Sagan. Now, when you encounter a function like this, which has, well, you online, then you can even omit this Carly bracket and then just remove this return and please is cost to India, and this program is also correct. So let's run this and you can see we got the same output. Also, you don't need to specify the data type in here, so that's right. It's cost two. And this program is also gonna be correct. So let's run this to verify this and you can see we got the same output. No, I'm gonna talk about the default parameters in cotton. So energy expended. Stop it. I'm going to create a simple interest, calculated Johnson. So that's right. Function and name off your function. Simple interest on it is going to take the principle as a parameter, and it is going to be of type int. And who's going to take the second perimeter as a time? And this is also going to be of type in, and it is going to take the are as a tour perimeter and it is going to be off life double. And inside this, I'm gonna return the interest. So our formula for interest is principal multiplied by time, multiplied by rate on developed by 100. So this is gonna be our simple interest. And it is giving us here. It says required unit, but found double. So when it is specified, the data dive here. So our data type is gonna be doubled because we're returning the double from here. OK, no, let's call this function from here. So bring Ellen on the simple interests we need to pass the data. So this parts principles $2000 time is two years and readers, let's see five years and you know to explicitly mentioned this five as a double you need to do do double Oregon, simply see to float. And here also, you can do flute on here. Also, you need to do float because we know that fluid is going to dig the lesson space. So let's run this program and you can see our interest is 200 now in here. If I do something like is a cost to on then when it did specify as to float referred to something like this. Then our default value will be to if I don't specify the raging here. So let me remove this. It is not giving us. You're saying less number of parameters then require. So in this case, if I run this program one more time, you can see our program is is still working fine. So the concept is, if you provide argument in here than this tool will place by their argument. Otherwise, it was going to take the default value. In this case, it is just taking the default value. So, as I already mention, if you encounter this kind of function, which has won the one return the statement, then you can commit the Corley bracket, and then you can remove this region and replace this with Is it cost two and also can return this float. So this is how are different argument works. Now let's talk about the name argument. So if I specify principle, it's cost to 200 here and time Acosta to then this kind of argument is called Name Argument . You can see I'm explicitly mentioning the argument naming here. I could do also something like articles to five or something like that. And we do change. The says float and let's run this program on Days are are put so they had wanders off. This name argument is we can Swiss the owner, for example. I can even change the partisan Let me through the boys and at this time, and this is also gonna be a value program. So the time that is teas assigned to this argument on the rate is assigned to this variable , so you don't need to worry about the order when you use the name parameters. Now let's talk about the different types of. For instance, there are basically three types of function. 1st 1 is top level Francine. Second is local Funds and other Initiative Johnson and Tories member function. So let's talk about the top level function. All the function that we're outside the class is called top liver function. For example, this manager top level function similarly dismisses full name simple interest the Zoeller top level function. Now, if I declare a function inside this function like a local function and inside here, I just want to see local function. So if you declare a function within a function. Then it is called local function are nested. Johnson. You can only call this function within this block. You cannot actually call this function outside this block, for example, it cannot actually call this local function from this main function. I can see it is giving us here. But you can actually call this top level function from the other class as well. For example, if I go to source and create a new court and file, let's see another file. Dark kitty. Let me quickly create a main function here. Now, I can always call these top level function from here. For example, let me call messes. And here I can actually passed the data. Let's see for name gonna be Apple Given can be baseball and it is there gonna be five and let's say seven. And if I run this program, I can see I'm getting the value in concert. The reason you are able to call this function is that all the top level function are by default public, and we are in the same package. For example, if I write here private and if I go to another file, then you can see it is not allowing us to call that function because it is a private in the file. So by default, every top level focus in his public. So basically, there are two kinds off modifies, public and private. When we're talking about the top level functions on when we go to the object oriented programming, there are other visibility modifies as well. So for now, just remember public and private modifies. So when you have the public label modified, you can actually call them from the another file. And by default, every top level function has a public modifier. So this is just the basic fundamental rap off a difference, since we're going to have a separate moral for a funk since one Lee on where we're going to talk about the different expression of functions and do a lot of exercise on them, and I will see when the next part 11. 11. String interpolation in kotlin: Hello, guys. So let's talk about this string Intra Palestinian chortling. No, I want to declare the two very well Foster for so first name on Did see Enjoy. And our second variable We're gonna be so name Let's say Smith. Now if we came from these other background then you might want to do something like print Ellen Hello. And then plus symbol Force name Then again plus and in the space. And then plus surname on Google Plus and then on your rest of a string. Glitzy How are you? So if I run this And here's our portrait says hello into a Smith How are you? So this is the traditional way of going but in court and we have something called a string Interpol. Listen. So what we cannot do? He's hello and then dollar first name and then again, dollar. So her name And then how are you? So as you can see, it is much more clean and easy to understand compared to that of credits Norway Solar. Soon this and you can see we got the same outfit here. Now let me show you something here. So let's see. Well, numb One is goes to fight and, well, number two his glass to 10. No, we can simply print these from off this number as between Delon. Some ease dollar and then we need to wrap this inside the Cali bracket. Numb one plus number two. So let's run this program and city or put you can see our output is script in, which is correct. So whenever you have more than one variable, then you need to wrap all those valuables inside the Corley bracket. Let me show you one more thing. So print. Tell him lint off spring is and let's see first name dot length. No, If I run this, let's see what happens. So simply it is not actually printing the length of this thing. Rather, it is after reprinting the string well itself. So in this kind of situation, also, you need to put the curly bracket. Now let's run this program and see what it results. American see, the length of the string is three. So we're going to use string into Paulison when we have to combine the twisting and we have to use the courtly bracket when we have more than one variable are or when we have to exist the property of some objects. Okay, so see in the next part 12. 12. Null Safety in Kotlin: Hello there. So in this episode, we're going to talk about the ulcer. 15 chortling. So, first of all, let me create a Java file here. New job, a class on din. Let's see, our last name is gonna be safety Java file here. Let's create our main function. Now let's get under the file. So new source this time, that skater court in file. So it's gonna be safety Katie file now Heroes who rescued our main function Now inside here . I wanted to clear one variable. So let's say our data. Let's see high. Now I want to us find this variable as a nal in here, and it is giving us error. Let's see what the areas. No, I cannot be of value off known no type of stream. So this means that whenever we initialize available, then it becomes no, no multi variable. So that's why it is not going to allow us to do so. But let's go to our Joe filed. Let's do the same thing in here Spring, our Dida and hi. No, let's assigned Noelle to our data against it is not giving us any kind of fear. And this is going to create the null point of exceptional in our runtime. So if I do something like length off screen, he's how data dot length. Now let's try to run this file first. Refer. Common this out faster for Let's Go Here and let's around this well and here again, see our job A is giving us the null point of exception. Now let's come to the our chortling file. Let's do the same thing in here. So let me remove this and, you know, to remove these era. We need to specify the deterred I and put the question mark in front of this intercourse. Two symbol. Now we can see it is not giving us other. Now let's bring length of the string here hour later dot Lent and he says, Well is safe. Calls are allowed it. So the court Lynn already knows that this might generate the Norman deception in the Enron time, so it is not going to allow us to do so. It's kind of syntax in here, so for that we need to remove this line and we need to remove this question mark and then we'll it is going to work. Second, see I cannot actually proceed with any kind of syntax that is going to gender the no point exception in her own time. So let's run this and you can see our Lent is true. Now let's go to our data file one more time. So we need to remove this line here, and that's it on this and you can see the length of the string is too. So for now, let me also remove this because let's have the same output and two. So we look at the same program in Javelin Corton, but in case off Java, it is not able to handle the whole point exception in her own time. But if you look at the courting file, it is already going to prevent us to write some kind of program, which is going to gender t no point exception in around time. So this is one case out off many case, which explains cardinal is much more better and powerful than Zaba. So 70 next class 13. 13. Making our program null pointer exception free: Let's talk about different ways that we can use to make our program no point exception free . There are a couple of metals that we can use to make our program. No point accepts and free Onda Performing Nordic mentally is one of them. So this is the simplest way that we can use to make our program now appointed exception free. So let's understand this approach with help off one example quickly. So let's create one chortling file. Let's see no CIF and here less great our main Felson. And here let me declare a available Let's say game and I'm going to assign this variable as football. So as soon as a in a solicitous valuable it is going to be no knowledgeable type. So if you try to assign this game as, ah null available and it stays, nor can it be a value off nominal type. So you know, to make this string as a nominal type unit at question mark before this is close to symbol and your game is now known knowledgeable data type. Now let's look at the simplest way that we can use to make our program no point accepts and free So let me write a comment here. Manual. No chick. And here what I'm going to do is if game he's not equal to know, then William going to perform my prison. Otherwise, I'm going to handle the case for no. So here. Let's bring the length of the string spring length days, dollar game dot lint. Otherwise, we're simply going to see this string. Length is, they say, minus one. So this is the simplest way that we can use. And if I run this, it is going to say String Lindsey's minus one. And if you hold on this, if simplicity is unreasonable, cool. And that's because our compiler is it smart enough to know that this statement will never gonna be executed? Because this value is already known here. If I name of this and if I run this and our string Lindsay's it. So this is the Force operas, and I know that most of you already family with this suppose now let's look at the second of those that we can use to make our program no point accepts and free in court line. We have something called safe call operator that we can use to make our program now open natives and free. So let's see a simple example. To understand this me see safe call foster ful as a comment. And here I'm simply going to say String length is dollar and then game dot Lent. And just before this dirt, I'm going to add the question mark. So this is called safe call. And whenever this value is now, it is simply going to say no here instead of 20 no protective zone and crossing our program . Otherwise, if that game is not know, it is simply going to print the length of give. So let me run this and we got the same output. Now let's say this again. Variable is no. So if I run this, you can see it says string length is not all. It is not actually pressing our program. So that's the important thing to notice here. And let's go and see another oppose that we can use to make our program now appoint exception free and the total bruises making use of Elvis operator. So it is simply represented by a question mark and then colon. So let's see this. So let me copy this that business here. Let's see L this operator and here I'm simply going to say question Mark and then Colon, and I'm going to say the default value so you can think off Elvis operator as the sore from off event else. So if you're game very well is not now, then it is going to print the lend off that string. Otherwise it is going to provide the default value. So it's a good idea to use the Elvis operator whenever you need to provide our default value when you're variable is now. Now, if I run this and our string Lindy's minus one now listen again. The Fort mentor Let me for sexually make it bring talent hair. Now let's look at another operas, and the fourth operas is we can use the lettuce co function so we can use the latest coffee . Listen, whenever we want to do sort in talks only when our very police and not know. So let me show you what I mean. So, Lucy, we want to print a massive whenever this again. Variable is not know. So for that, I'm simply going to say game on question mark and then dot and here I'm going to add the lettuce golf onsen, and we're going to talk about in detail about this latest Alfonsin in our higher a function model. So for now, just remember, we can also use the latest core function to make our program now all point access and free in this block. I'm simply going to say I am not No. So, first of all, let me run this program and I will show you what's going on in here and here. This block is not executed. And this is because our variable called Game is now. If I m this and if I run this now and it says I am not know so I hope you got the concept. So whatever you right inside this call a bracket, it is really going to be executed whenever that particular variable is not know if this very well isn't all, then it is not going to execute. Okay, so there's a very simple concept, but it is very powerful in making our program in our point excess and free. Now listen to get 100 operas and the next operas is not know assertion and it is denoted by two exclamatory science so you can use not no losses and only when you are only person show that your variable is not know otherwise the compiler will going to give, you know, point exception. So let's see this and hair If I do dot length and we know that it is going to give us error and it says, Well, is safe Operator or normal asserted calls are loaded on a knowledgeable receiver. So by adding this question mark are variable is knowledgeable right now. I know to run this statement, I'm just gonna add double exclamatory sign. And it just gave the order that this game variable is not know 12 the program. And you said proceed normally let me print this pre Engelen knife a run this and he says it which is working Fine. But let's see, when I signed this again variable as no. And here I have asserted that this again is not know. So if I run this on Quincy got the normal point exception. So you always need to be 100. Wasn't your that your variable is not know if you want to use this symbol in the simplest form, you're going to use this not colossus and or prison. If you want to do some prison on no level available and you need to be 100 wasn't sure that your variable is not No, and I will get you in the next episode. 14. 14. Late initialization and lazy initialization in kotlin new: So in this episode we're going to talk about the two kinds of in is a lesson in courting. The 1st 1 is letting this resin on. The 2nd 1 is laziness. Listen, so let's talk about the use yourself late in. It's a lesson. According to the Courtland, every properties in class must be initialized. For example, let's say we have a class called game, then we must initialized this name property with some different value. Otherwise, when you do make this name property as they are knowledgeable, and then we need to assign this property as an all value. So we need to choose anyone off them whenever we're declaring the properties in Scotland. But this is not always disputable case. For example, in under developing variables, maybe insulation the lifecycle metals, for example, we may need to initialize are variable in honor, test metal or on the start metal own create metal. So this is not suitable. In that case on, let's look at another example in case off unit testing, our variables are insolence with the help of centers are set of matters. So in this example, also, this kind of approach is not suitable so independence injection tool. The variables are initialized through the injection, so we may not know the value of variable at the time of Greece and off the object. So these are some of the problems with property, and it's a lesson in Cortland. So you know, to overcome this issue, let in it are letting Celestine is used. So if you drag races that variable before in, it's a lesson, then you will get on in its allies. Property excess EPS Epson from the compiler Let's try to initialize are valuable with help off, letting this a lesson concept. So in our Hira Pakis, let me create a chortling file. So let's give the name as let in it lazy and inside here. Let's good or men Felson so this below this main function. I'm going to create a class call game, and this is going to have one property call name and it is going to be of type string. And let's sign the default values football and let me create a function called So Messes and let's Bend game. He's let's see name Chris that this is the basic set of full hour plus, so this is the one way that we can use to initialize our variable. There is another way, and that is let me come in this out and I can actually who placed this with no hopes. Let me pissed this football with no and I didn't hear the question mark in her to make it knowledgeable. So this is the second operas, and sometimes we don't want to add no here also, and at this kind of situation, we're going to use the letting it and this is going to allow us to declare the variable without insulating it. Now, in our main function, let's create the object. Let's say, Well, G and game. Now let's see what happens if I tried to exist this name before any solicited. So let me do print and z dot name. If I run this, let's see what we get. Only conceive. We got the whole insolence property access, every person. So you cannot actually break that deal that you made with compiler. You always need to initialize this valuable before you can exist. Him so deeded name. Let's see cricket and no, If I run this, it says cricket. I hope you got the concept we can also call z dot So Mrs So there's a normal thing. So if I run this we got game is cricket and there are some sorting tools that we need to follow whenever we want to declare the variable with a late in. It's a lesson. So let's see is of them. The first rule is the property must be mutable. That is, it needs to be a liar in our program. If I tried to make this name as Val and it says Litan, it modifies allowed it Wiljan mutable properties. So always remember this. So whenever you want to declare the variable with legislation, you always need to make your variable as well. That is mutable. No, let's see the second World and the second rule says, letting it is not allowed it in primary constructor. So let's create a primary constructing here now. If I tried to add letting available, let's see clear on a string and it is giving us some era there, see what it is. And it says letting it modifier is not allowed it on primary constructor parameters. So you're not allowed to write letting it in here. Okay, so I hope you got the concept. So let me remove this primary constructor. Now let's see the total and the total says we can also use the late in its allies on the top level property. So, you know, top level six and let me do letting it very and let me create available call. Let's say lazy, innit? Variable and it is going to be off type this thing. Emergency were also able to use the letting it in case off top level property as well. And rule is same. We always need to in its Celestis, valuable before we can exist them. So let's say it missile ized. And no, I can exist. This variable on. Let me went out one important thing here. You always need to write dealer time if you're going to initialize your variable with the let initializing method. So if I try to remove this and he says, and the property must have, ah, type entered isn't our initialized. So let me actually under this now let's go and see. Another rule on the fourth, Toral says, are late initialized variable. Most wanted be null in all type. Select. See what it means as we know this name is innocent is with help off letting Cillessen, and this is going to be null null if you try to make this says that, knowledgeable. Let's see question mark in here. Then it say's letting it wander far is not allowed it on properties off fallible type, so available needs to be no knowledgeable type. It cannot be knowledgeable type. Okay, so let me under that scenes. Now let's go and see on the rule, Fitful says. When the primitive data types are allowed it for lead in, It's a lesson so it is not applicable for into flowed bullion. Doll s extra. So if I try to let in its allies available, let's say roll and let's say it is of type int. Then this operas is not allowed it. Our data wraps and not be premeditated. Type can see it says let modifier is not allowed down. Properties are premature type, so you need to remember this whenever you want. Riddick clearly variable with letting this a lesson. Now let's see under the rule off late in, it's a lesson six Rule says you can use this in itself. Is met her to check whether we have any select that variable are not so here. I can simply do this and then call and Colon. This is a function reference by the way on, Let's in name and I can do is in this race, and I can wrap this inside if a statement and let me put that inside this, if is, let's see. Variable is not initialized is not initialized. Now let's say this game is not in its allies in here on. Let's come in this hour. Print Ellen also know let's run this and let's see the result an urgency. It says variable is not in this list, so you can use this matter if you're not sure whether you have in Italy's your variable or not. Okay, so that's a good thing to remember. Why do you can remove this this cable in hair and this is also going to work, and there is one constant that you need to follow. You cannot use easiness as metal outside this class. If I do G colon colon name, then I cannot use easiness less metal in here. If I try to do this, then you say the very name is not accessible at this point. Okay, so you need to remember this And this is all about letting its allies and in Cortland So let's see how we can use laziness lesson in Coplin. So in case off laziness, listen, we're going to initialize are variable with help off lady function that takes lambrecks prison onda laziness. A lesson method can be compared to the single agent patron. So first of all, it is going to check if the variable isn't null, Then we're going to initialize that otherwise we're simply going to return that in its allies very well. So the simply put lazy creates an instance that performed in isolation at the force exist only properties, and then it is going to store that value, and then it is going to return that value. So whenever you use and get her for the first time at the time, it is going to be initialized on offer that it is not going to be in its allies. It is going to return the same value that you have initialized for the fourth time. So let's see some examples. So here let me declare, Oh, very well. And let's say player name on. I'm going to insulate this value with the lazy approach. So we're going to riding by and then lady. And here you neediness Ladies value. So let's see him, Messi. So let me form of this. So for that you can simply say office uncommon and then yell. And here again simples e d dot and then player name and let me bring that and let's run this and it says Missy, And there are some Bluth that you need to follow while declaring your variable with the lazy insulation operas on. We're going to see it with the help of comparisons. Art between Litan is a lesson and region insulation. So in case off late in its Eliza R variable, can be initialized from anywhere where the object is accessible. For example, our name Mabel can be initialized from here. Let's see. First name are from here also. Okay, you can exist them from anywhere. Let CNG dot name, but in case off laziness lesson variable can really be initialized. Bomb initialize er lambda, for example. I cannot insulate this valuable from here. I can really insulate that variable within this lambrecks present. Let's say Fernando so I cannot do d dot Did her name in here, and this is not going to work. So let me remove that and let city one of the world. And in the second Will Venable can be initialized any number of times in case off letting insulation. But in case off laziness lesson, you can only insulate that variable one time. So let's see this. So, for example, I have any solicitous variable couple of times, for example, in here and here and heroes, right? But I cannot in its allies this player name again and again. I can will insulate their variable in here. That is only one time in. It's a lesson on the charge. Will say's are variable can be used for valuable e r variable can only be used with Belle and the rule number forces are variable is not trade safe. And our laziness as variable is third safety bite if all because it is a known mutable time , right, So we need to pay special attention whenever we're doing the multi training in case off late in its allies valuable and the few princes and its interests can be used to check whether the properties initialized or not. So we talk about this, but in case off laziness a lesson our property is always gonna be in its allies and the people says are variable is not allowed it on the properties are primitive jerry types and in case of laziness, allies variable. We can also use this concept for premature data types. Also, I hope you called the broad idea about this concept. So Stephen D. Next up, so 15. 15. No Automatic conversion: Hello, everybody. We're going to talk about the type conversation chortling. So first triple carries example file in the left part on Thursday, courting file in the right part. So listen, declare two variables in job masterful into someone. It's cost to 25 long numb to it because toe numb one. And this kind of syntax is a valid in case off Java on the smaller number is ultimately converted to the large number. But if you look at the Courtland, situation is later be different here. So let's do the same thing here of our number one in his cost of 25 of our number two long the cost to someone. Then you see it is giving us theater and stays type Miss Math. So increase of courtly. No, we have to explicitly convert this to the higher number. The Courtland will not going to convert our a smaller number to the high number. So we have to achieve this functionality with this helpful function. So willing to say numb too long on this is how it works. And this is also a notable difference in case of Java and Katelyn on. I don't know whether you like this explosive, conversing or not, but this is how it works in case of chortling already. So let's meet in the another lecture. 16. 16. If else in kotlin: no my soldiers. And in this episode, we're going to talk about the NFL's straight men in chortling, and we're going to write the very, very basic programming here. The program is going to find the greatest number between two numbers, so have opened. The two files in the left side have opened the jar file, and it's right side a have opened the chortling file. Okay, so let's right the same problem in both programming language. So let me declare two variables. Festival numb three cost will see 25 change numb for, let's say, 100 and listen to bureau very well called Max. And the program is very simple just to no, um, three million or recall do known. For then our Mex he's numb. Three. Otherwise, our Mex variable we're gonna be numb for Let's bring this message in here. Java Maxi's Max. Let's read the same program in case of courting Vier numb threes. Cost to 25. Fire number four. It cost 200. Let's declare the very well called Max, and it is a in teaser and hairless do. If Max three hopes numb figure recall too numb four. Then our maxim is gonna be numb. Three Simple else Max going to be known for Let's print this year. Court Clean Maxi's Dollar Max. Now let's run the court in file. First of all, and it say's Max is on it with this carp. Let's run the Java program. Also, it's over Maxie's 100. So both program are correct. In case off court clean, we can treat the FL disturbing as a expressing, expressing instantly the statement with returns some value so I can add, is Acosta in here and let me remove this Max and it may remove this max from here as well. And this program is also totally valid. We're going to return the norm tree from here. If the condition is true, otherwise we're going to Candy known for. So let me on this file and we got the same result and we know that this condition is gonna be falls. So let's write something in here far known. Five. Because to tree bus five and let's run this on, you can see it's still relearning the known for that is 100. So no matter how many lines you write, it is always going to return the last statement so norm trees obviously Liston them for Therefore it is going to come into this else part and it is going to deal with this line and returned this non for in here. No, let me close this now if I do the same in case of Java and it may remove this against the our job or doesn't support this kind of syntax. So let me under this. And this is all I have to cover in this video and I will see even the next class, so save then. 17. 17. Input Output in Kotlin : Hello, everybody and this appeaser. We're going to see how we can take the input from the user from our concert. So, first of all, let's create one for alcohol user input, Dark Kitty. And here, let's get our main function. So first of all, let's to give a message to a user seeing Inter your name. I know we need a mechanism to take the input from the user of our name. It is type of a string on you not to take the spring data from the console. We just need to see read line dot to string on this relearn function. We're going to take the data from the council and put that data into this name Variable. So let's bring that variable hero print Allen on Let's say hello name Okay, so let's around this program and here is our program and it says, Enter your name. So let's inter around name, let it be done. And if I hit enter then it says hallowed zone. So simply, we're waiting for the users import. And as soon as you the interested data, we're going to print that daytime here. All right, so this is what you need to do for taking the input, The string from the concert. But what if you need to take Thean teaser are flowed or double from the concert. So for that unit import one class called a scanner from these Arba Standard Library. So for that you just need to say of our scanner. This is your available him and it can be anything you want on simply unit to see scanner on inside. This is Canada unit to say system and then you to say back Dick and I am in and again Batic on this back Take symbol is just below your escape key in your keyboard. So let's import. This is scanner plants from Java on old entered Import that and then imported about that. You till that the scanner class on Once we have the object off a scanner, then we can simply say var roly cost to a scanner dot Next int on this is going to get the into severely from the concert. So let's print the spell, you know, print Ellen. Let's say your roll number is this. Let's run this program And here's a program. Unless past the name as Sam on let me hit enter. Then it says Hello, Sam. And now it is expecting Indies available from the users. So let's pass three. Andi If I hit, enter and then it says your rule A ministry. So whenever you need only string from the console, then you can use the re lined or twisting. And if you need the data, like in teaser or even float our long then first unity import the scanner class and then applied the corresponding funds in there. Okay, so this is what I want to mention in this lecture, and I'll save Indy next lecture. 18. 18. When as a Statement: Hello there. Let's talk about the witness statement in Katelyn and here have one main franson on another . One is Result Funds, and this result function is taking the marks as a perimeter with itself type end. And here I'm calling that a result from a couple of times with different marks. So we all really learn how to create the function and how to pass the parameters in the function. So that's where I skipped it portion. Now in here, let's see how we can use the when a straight man in car Flynn. So if your family with the sweetness treatment in your previous programming language, then it is exactly the same. Only the middle off writing is different. So first rifle, we're going to say when and inside here we're going to pass the parameters. So let's pass that perimeters marks on delivery to open the Corley Press and close their Corley breath. And inside here we're going to take the different condition. So far, so ballistic. One condition in here, in order to city condition, is simply write the condition first rifle. Let's say Totti do. And if this marks he called it hard to do the score will be executed. Let's say print Ellen just passed on. And if the Marks is 50 then we're going to say Not bad. All right. When the Marks is 70 then we're going to see good marks on when the Mosses 90. Then we're going to see Excellent. And if none of this case man said, then we're going to see talk to the principal. So let's see, one day one first of all this mean function is executed. And when the user calls dysfunction result with the perimeter hardy to then the user will come in here and then the witnessed Erdmann will evaluate that mask and then it sex. If it matters to the case, then it is going to execute this line, or is it takes whether this matters to this case or not, it doesn't matter if they're going to take this on this, and finally this court will be executed. So meanwhile, when a user call this function result with Parametric harder to this line, we're going to be executed and the rest of the line will be not executed. And for this case on the masses, 50 wanted this land. We're gonna be executed. And if you look at the case for 45 none of this case mats. So that's where it is going to have to give this line sellers on this program and see. And here is the output in the first case, it saves us pass In the second case, it says not path. And in the tar case, when the market is 45 then you see there is no case for 40 fire. Thus, it is going to say Talk to the principal and for the excellent and good marks I can see in here 90 cents for excellent on day seven distance for a good marks on. In this letter, we saw how to use when as a statement and in the next lecture we're going to see how we can use the who in as X Prison. So Stephen D next lecture 19. 19. When as a Expression: Hello, everybody. And this lecture, we're going to see how we can use the wine as a Expressen. So I created one file call when experts and are Katie. And then I copied all my content from the winning Steadman and paste it here and made some modification. The first modification is that I changed the function name to result for and I call this result one function inside deep in Tallinn. So I also did a similar thing in here as well. And inside the result one function I have declared available call data on Dahab initialized this data with this win Expressen. And when our Marxist article then this one expressing is going to return this data on whenever our Marxist 50 Then it is going to return this on when Marx is 90. It is going to return Excellent. And with masses 45 Then it is going to region. This the statement on once the statement is returned from this way next present were placing that response into this idiot available on simply turning this data. From here on, you can see this function can return the stream data type and once the valleys return, we're going to print that friend to D council. So to describe simply, we can use the way next person when you want to return the data from the one class toe a particular variable just like we did in the even else case as expressing Let's run the separatism. And here is our output, which is similar to that of previous one. So I just quickly covered this wedding statement and when expressing, because these two are small concept. So I hope now you understood how you can use the win as expressing on I will see when the next lecture. 20. 20. Calling Kotlin Function from java and vice vera: Hello there. So in this episode, we're going to see how we can actually call the job function from our chortling file and also can be looking at how we can actually call the chortling Frandsen from our job a file . So let's create our Java file. First of all, let's see our Java file Onda. Let's create our main function in here and here. Less good one multiplication function public static string multiply. It is going to take the two parameters Onda We simply need to say every town that's CNN's Oba I want to play hey s will be now let's get our core clean file are coddling file Let's quickly create our remain function as well And here let's create one function which is going to add the two numbers So Johnson hired it is going to take the two parameters as well. What is off, Captain Teaser on it is going to return the string See chortling hideous in a plus B Now let's call this chortling function from our Java file Now. Before that, I want to show you something. If you go to the out proxim aan den chortling you can see for our every court in file there is corresponding dot class file. So if I simply around this while here no agency are sour filed our plans and our Courtland file a kitty, their class files are generated automatically. Now we're going to make use of these. Are courting phallic 80 class in order to call this function from our class. Suffer that, we simply need to say so let's call this forms an hour cotton file kitty dot and we need to call this function. Add. So let's are two number as five and 10. And if I run this, it says chortling. Edison 15. Let's call this modification function in our Java file from the court in file. So it's gonna be Engelen and our profile dot Multiply this multiply five by five on Let's run this and it says Java multiplied 25. So this is how we can use our phones, um, in both Andjaba on Gotland at the same time. Now let's say you want to have a different name for this hour courting file Katie their class. So for that, you need to air the energies in. So at the top of the file, you need to say file colon TVM name and then you can read anything you want. So let's see Apple no affair on this. Well, guess what else You need to read the apple. Let's run this Now we can see our class Name is seems to apple. So this will help you to remember your class name erect. So this is what we're going to cover in this video, and I will see even the next part. 21. 21. String operation in kotlin: hello there, and this morning we're going to talk about the different stringer person in Scotland. So first of all, let's look at how we can compare the two Spain chortling prices to oppose to compare strings. The 1st 1 is competitive operator this or preacher checks for this cross a liquidity that is it. Six. Whether twisting, let's see and be content seem, did or not. And there is another, equally tickle reference illiquidity in case off reference. See liquidity. We're going to take whether two objects are pointing to the same memory location or not. So let's see how this operator works in our source. Pakis. Let me create a Pakis. Let's see, this spring a prison. And inside this Pakis, let's create a file called this spring a prison and let's create our men funds and in hair . Now let's use this operator. So first of all, I'm going to declare I string. Let's call it this ring A and I'm going to assign this failure as let's say, I like car clean. Let me in to clear another available. Let's say a spring be and I'm going to assign this value as I like chortling as Well, now, if you want to compare this to string, you simply need to say, if this spring hey equally quill screen be then we know that this twisting are equal. Otherwise these things are not equal, not equal. So let's run this program and we got the output. We says equal. Now let me change the system toe I love courtly in now. If I run this, it says not equal. Now let's look at another opposed to compare this fine and the second operas we have is compared to extents and function. So simply within to call the compared to on our forces string and then we're going to pass the second string in our perimeter. Two strings are electrical equal if they have same length and same characters in the same person on don't worry about this from lexical equal. We're going to talk about this very soon. So this remember, if to string are equal, then it is going to return the general. Otherwise it returns the negative value. If string A comes first and regions sports tip. If Palo of a string be comes first and here is a competitive start to understand it better if the region value is Gero, we're going to say the two strings are equal. If the region values negative, then we're going to see history. E comes first. Otherwise, we're going to say String be comes first posted in Desiree's return, and you're going to understand the concept of Let's say, a stringy comes first or the sting beacons worse once we talk about the lexical equality. So let's look at the lexical tool. The alphabetical order off for scatter deter mines with the string comes first, So let's see the meaning of this rule. So let me assign some data in our previously string call. SVK. Let's call it Apple. And in our string, be little sign as bull. Now go into this rule alphabetical order off First Cata deter mines with this drink on first. So here you can see that the car to a cons. Wasim Virginie and be now if I say a string a dot compare to let's pass a string being here and we know that this is going to return a in teaser valley, right? So let's assign that value in here. There's a very cost to result and we're simply going to take this result if result equal equal Jerro then we're going to say equal otherwise if result less than zero then we're going to see it. His string he comes first. So the rule is if the result is negative then our string a comes waas That is the spring in which we're calling the compared to comes first so you know, is gives let's see his spring be gums first and are going to this rule. Our destiny comes for threat because alphabet a comes supposed to compare to be safe around this It's it's a stringy come first and there we go. Now let's look at the second rule and we're going to second rule since is all uppercase letter come before largest So let's see this. So here let me actually copy this on the condition here on let's remove this market But in here and instead of apple. If I write zone with Capital Z, then in this case are resting s that comforts compared to how resting be because jetties uppercase and bees lower keys knife I run this Let's see what this is. And again it says spring a comes first. Now let's look Daddy Total and are going to the total if to string are same. The alphabetical order is used. So they see this. So in here. Let me actually copy this one more time. Then let me patient here and here. Let me make this capital G as small. See any proceeds own. Underscore a And here, let me see John Underscore. Let's say B and in this case, our testing. It comes 1st 1 more time. Because after this and zone and underscore both the stringer seem so we're going to make use of alphabetical order this time. So it comes first. Then be so are resting. They were going to come first. Okay, so let's run and verified Answer. And here you can see destiny comes first. Now let's see under the rule and the fortresses if to stream Content City, Same character in this same person. Then the sort of string comes first. So let's take this out. So here again, let's copy all of the score and paste it here and here. Let's right, John A, B C And here list, right zone E. Now, in this case, history be his prison in issuing a also But since how listing bees, the sort of system it is going to come for us so far on this, it's it's a string be comes first on de Rico. It says the string be comes first. Now let's go and look at the people. And this will says we can pass. Ignore kiss, flag to ignore case and by default it is said to falls. So case always matter by default. And if you won't ignore the case, he can pass this black. So let's sit this out. So here also Skopje. Go above and paste in here. Let's say Apple and spring builds less apple. So these twisting are seems. If I run this, it's a sequel. Okay, so about Brezik will? No, if I may modify. This is small A to capitally. And if I run this program it said the string it comes waas because this is capital and they're going to our rumor to our Purkiss later comes first. No, let's say if you want to ignore the case, then you need to pass. Grew flag in here Now if you run this, it's it's equal. There we go. OK, so this is all about comparison or prison in history. Now let's look at some of the other ah presents in the string. Let's see hope in the youth e replace are present in our screen, so we have extends and function called replace to replace our spring. And here is the definition. So simply, we're going to pass the old value off a swing and dinner desire string. And then we can pass the ignore case here as well so we can see by differently. It is said to falls, and it is going to return the history. Now let's understand this with example. So in our pack is called a string or prison. Let's make a file and let's see more a prison in the spring in this great army in Folsom And here, let's create I spring. Let's call it as messes and inside, hey, just type. I am learning core clean programming chocolate magically remove this and make it as got Wendy. Now let's see Business court with courting Sousa strive well and result, and the stripe messes and dart replace, and here you need to pass the oldest thing value that you want to replace, said the spring. We want to places court and we want got Lynn to be the new value there. And here's a spring. This result and let's run this and it says I'm learning chortling, programming knife. It's a sprint messes here. If I run this, it says, I'm learning court programming and here it is, a place with courting. Now let me drive a small gain here. If I run this score, let's see what is going to return. And it is not actually placing our court. And that's because we have different case in here. So if you want to ignore this case, it's need to pass through in here, and this is going to ignore the kiss. Now let's learn this, and we got the proper output again. Now let's look at the another prison in his swing. Now let's see a way to speed out a string. Now you notice Pittis ring. We can use the split function, the speed spring into multiple parts, and it is going to rejoin the list of a string as an output. Now let's see, its example here are just type of result and God is played, and then unity specified the day limiters on with You want to split that a string? So for the time being, let's speed this string whenever we have space in between. And as I have already mentioned, this esprit function is going to adjourn the least. Travis String. So let's a store that variable in our let's is pleaded screen very well. So since this is a list registering, we can simply say for item in this pledge, it is scream. And inside this godly record, we can see print item, and this is going to print all of that a string. Now, let me also do print Allen on display truly string here so that you can understand what exactly we're getting inside this variable. So let me run this and here against evil God, the list off a string. And here were simply printing each of those item in here, and we're going to continue our restaurant. The string of prison in next episode 22. 22. For Loop: and from the six. And we're going to talk about the lows on in this flexible and especially focused on the for loop. So let's create one file call loops and OK unless great, our main Funston here and here. I want to create one variable call countries, and it is going to be ari of country off data type string. So let me add some countries name here and now we're going to write a for loop to reiterate through this area. So first of all, the uniter type for on then you need to specify opted name, so it can be anything. So there is no boundary it'll. But the convention is that whenever you declare Ari, it should be poor. And in here it's it. Be singular are simply unit quantity. If it on then the unit to type I am in. And then you need to say they are a name which is the country here. Andi opened the goalie breasts and closer cruelly best and just I print Allen on just a country andare Sit. This is the four loping, chortling and hear this country's is this conditioner and this country is this country here Okay, so let's run this program. And here is our list of those countries. And I want to show you one more method that you can use to literate through this for love. So for that unit, do for on you need to give the index here. So let it be I and then give a space and the type I and in and then type countries that is there a name, then type in. This is and this industries is the property of the area. Andi opened the calibrates on closer calibrations Will on Just try print Ellen. And here it will be countries on open the big bracket. And inside You just passed that I in here. Let me move on. Let's run this program on Heavy have printed their countries one more time. Okay, so I hope you understood how we can use the full up in the chortling on. I will see you in the next episode where we're going to talk about the while loop 23. 23. While and Do While Loop: Hello, everyone. Welcome back. And this lecture We're going to talk about the while loop. And do I look in Cortland while? And do I Look works in a similar fashion to that of other programming languages. So there is no tins, etcetera. Andi, I want to show you how you can interpret this country's array with help off while Low Foster pull on. After that, I will show you how to treat it with the dual look that imprint masses foster for for why? Look, this declare are available. Call I on. Let's initialize with Jero and in here you need to drive while Andi opened the bracket. Close the rocket. And inside this bracket, we need to right, first of all, the condition. So the condition will be If I list than the size of this area, then we want to print that. So let's print this on. We just need to say countries Andi, on open the big bracket on pass our index call I and here we need to implement are in this , and this is all we need to do for the wild case here. We're going to take the condition. If the Conditioned men's they're going to execute this statement within this block on. Otherwise we're going to come out of this while look and let's look at the Do I look me bring masses, Westover for Do I look unlisted? Declare one of available quality. Let's initialize this with Jerry as well, and we're going to execute first block without saying the condition. Print Ellen on. It's gonna be countries on this past step index in here. Onda. Let's implement that index. And here we need to see a while the Liston size of this area, then executed next to reason. So let's run this program. And here is their output for the wild. Look on Harris out before Do I look and I hope you got the concept of how we can use the while loop and do I look and I will see when the next lecture 24. 24. Ranges in Kotlin: Hello, everybody. I hope you are doing great. And in this episode we're going to talk about the reins in cotton. So go to the project. Let's get a one file call Ranges. And here, let me show you the how you can use the reins in Coughlin. So let me print a mess. It's possible it is going to be Kiss one. Let's use the four low for it irritatingly ranges. So first of all, you need to see far on. Then we'll index let it be. I on in on for rains. You need to give this starting point on dot dot on din. The in point on this is your reins in the carton, so let's bring it here. Bring I on. Little on this on. Look at that. It prints from one to fight. Let's look at the case number two on this, timeless to something opposite to it. So that's forced the terror index on. We're going to do in, and this time we're going to reverse so five down to one. Let's bring this on. Let's say drawn. And for the kiss number two, it gives the result from 5 to 1. Let's print print Allen here. Now the output is clear on DNO list. Look of the under the way of educating our origin's print. Ellen Print Allen Case number three And in Here. We're going to do something like a for I in and then from 1 to 20 and we're going to give this tape stay because to To And if I print this on, it is going to bring all those numbers except divisible by two. So let's run this application and conceit is printing old. There's 13579 11 13 Except all those number divisible by two. All right, so this is one quick to tell about the interest in off Ranges in Cortland on aisle seven the next episode. 25. 25. Break Continue and Labels in Kotlin: in this episode, we're going to talk about the break continue and labels in Scotland. So let's start off all appear and this follow. We're going to start from 1 to 20. And let's print this. No, If I run this program, you can see we have printed 1 to 20 Now sometimes well doing program. We need to escape some condition. For example, if I cost too for then we don't want to bring that number. So for that we're going to use the continue. So if I it's cost toe for, then continue now. If I run this program, you can see it is printing all the numbers from 1 to 20 except for so first of all, it is going to print 123 And as soon as it encounters world is cost two for a. Then it is going to execute the continuous German and this continous generally going to escape old or prison in that particular to reason, whenever the eyes for it is going to escape this and then again it is going to continue from my goes to fight. Now if I use break instead off continue, let's see what happens if I run this and you can see it is printing 123 As soon as it encounters I cost a four. Then it is going to break the for look and then it is going to start from here. So if you want to skip old are present in a particulate reason, then unity. You see continue. And if you want to skip the for loop as a whole, whenever you get some conditioned, then you're going to use the brakes treatment. Now let's talk about the labels in chortling for that, let me create to fall appear. Hi. It is going to start from one. Do three and I'm gonna create instant for Libya. It is also going to start from 123 Let's bring this number in here. I and Z, once the inner for loop is complete. I'm gonna give me one new line here on. Let's call this as case number five, Case number five. So let's run this. And this is what we get for the case Number five. You can see this is our case. Number five. Let me simply copy this and patient here on admit this is case number as six and we're going to make all the changes in Case number six and compared them with the case number. Fight are here. If I used the briquettes treatment, I would see I cost two D and break the riches. One. You're going to exit from this for loop. OK, so let's run the centric denser. You can see when I cost a day. Then it is completely ignoring the inner for loop. And it is going to start from the outer for loop. And wherever it encounters this partisan than it is again going toe exit from all this for Look, I'm going to start from here. That is the outermost for look, let's do the continue Studeman here. No, let's see drunk. And here let's value the gifts one more time. So if I e custody, then it is going to escape this person so you can see there is no 11 in here, but it is going to start continue from that innermost for loop on. It is going to print this and one of age. In contrast, this person it is going to skip this and again going to start printing from this and it is going to bring anyone tried to do on one of get high cost a three and they cost a tree. It is going to edit the main parties off this case sixties, understanding the labels. So let's go for that. The force of unity gave the name to the level. It can be anything you want, so let's see anything. And then you need to give the other its symbol. So this becomes your labor. And here you can actually do something like continue at anything. Now we never program in Congress to condition it is going to continue from this order for Look, now, if I run this, you can see this is a result. Let me explain you here. So here it in contrast, e one and one. So it is going to completely ignore in a group and start from the outer loop. So that's what is going to print the 21 in here now, as soon as this encounter just wanted to, and then it is going to execute from the autonomous for no so 2122. And this is all I'm going to cover in this video and receive in the next episode 26. 26. Extension Function: Welcome back. In this episode, we're going to talk about the extends and functions in court. Lynn. So this is one of the important features in Courtly in which makes it so much powerful compared to that off zaba So chortling allows us to add additional function toe a particular class, and I'm gonna show you the suitability of the extends and function with two examples in this part. So, first of all, I want to create three in teaser values. Cost O. C. Five cost to that's it didn't and c cost. Oh, that's the 15. So you never artists. I can simply do something like this. The very basic operator like this, and it is going to air the three numbers. But what if I want to make the generate function which is going to earth it? Free numbers. If I do something like this, you can see there is no function call aired in our in desert object. So canal the extents and function to the anti surpassed like this. So fonts, um, in teaser don't head and it is going to take the two parameters that seem numb. One. It is going to be a guy paint and number two, it is also going to be off. Guys end and it is going to return the Indies. Or did I from here? So let's a return This plus numb one plus numb to And I will explain about this keyboard very solidly. So let's call this from from first of all and then some of three numbers, he's still Val. Some e dot And if I do hair, you can see we have the function called head now. So this is the extension function. Now we can simply say B c and pay special attention in here. I'm not actually passing the variable a inside the perimeter. I'm only passing the two variables BNC and I'm calling the expense and function call. Hello. With the help of a here, this keyboard represent city a value here, suffering simple. This will be equal to this. So here is a place with this cable. So this simply evidence the object which is calling the extents and function. Now I can simply say dollar some in here. Okay, so let's run this. And who is out for some off three numbers is tarty. So this is the force example now I will. So you so let me actually make this balance. You know, there is no point of making that value. Now let me. So you second example and with that, you will be much more clear with the actions and function. Here. Let me create a class called calculator and it is going to have the to function for us. Fourth, Annie's hair on it is going to take the two number and is going to rejoin the Indies. Their value we can simply to a plus B. And let's say it has another function. Cold sub crescent. He and the hint A minus bi. Okay, so far, so good. Now in here. Let me create the object of this calculator. Cost to Cal Villager. Now, let me call these two functioning here. So print Ellen some ease dot hard. Let's are 20 and 20 and let's create another function. Calls off. Jackson can't listen minus cracks in here. This do 10. So if I run this on whose order listen and hear is oh sub cracks on. Now the question is there. What if I want to have another function column modification without hearing any function to this calculator. In their case, we can actually do something like this function on a calculator dot multiplication. So I just created the extent and functioning here. This is going to return the Indies er so, first of all, we have to pass the parameters in here and be in, uh, lifts returned this multiplication from here. Now, I can call this modification from here as well. Let's run this on her is a model of case. So this is how we can add the original function to the pretty final classes with the help of excellence and funds. Um, so I hope you undershoot the uses of actions and function, and I will see you in the next episode. 27. 27. Infix function in kotlin: Let's talk about the in fix Bronson in Gordon in fix function is a special kind of function where it follows the three important rules. The first rule is in fix funds and must be a member function or extremes and functional. The second rule is it only contains one perimeter, and the tard rule is they should not be any bare argument or default value. Now let me So you with the example here, I want to create extremes and function, which is going to add the two numbers. In the previous video, we created the accidents and function, which is great TRD free numbers. But this time let's make the extents and functional, which is going to add the two numbers. Let's see function int. I had two number, let's say, and this is really going to take the second barometer. That's Intissar, and it is also going to return the decided tonight on this plus be okay, So this is our actions and functions on an organ make it infects function. We simply need to say in fix head of these funds and keyboard. Now, once I make this function as a in fix function, I can simply do something like in here. That c engelen some off to number is dollar. And then he had to number on. I'm gonna pass the scene here, So this is going to give the result off submission off E N C. So let me run this. And our answer should be 20. Some of to number is 20 great it want is of in fix function is it increases the readability of fork or what I mean by is that you can remove this daughter preacher and also these bracket and again this is going to run perfectly fine. No can see our core is much more readable compared to that of God. Operator and bracket and all that. No, let's run This output should be same against some off to memories 20 There is no problem. You know, we can also do this and it can also the daughter Britta it so off to you. Let's see what happens if I tied to air the default value in here. It is definitely not going to work. It sees shouldn't have very enlargement or perimeters with default values. Okay, so I help you understood the uses of infections and So it is used to make our court readable. And it has those tweeters. Let me remind it for you. The first rule is it must be a member funds in our accents and function. And the second rule is it should only have one perimeter on the card rule. Is there certain every variable argument and default value. So this is a quick to drill for inflict Swanson and I will see you guys in the next part. 28. 28. Function overloading in Kotlin: Hello, my wonderful people. In this episode, we're going to talk about the function overloading Fonso. Noble loading is the process of defining the same function. Name with the different number of parameters are different types of parameters. So let's create a file car funds and overloading on Let's greet our main Johnson. So first of all, let me create a function called Display. This. We're going to help the two in desert Buyer images, and this is going to return this ring on Lexi in age cost $2 A and into being because to dollar B and this time I'll create a function with the same name, but with the different number off perimeters off in Visa type. So Johnson display. So let's pass one pyramid at this time on. This is going to return a spring Duke into it. Cost. $2 e No, Let's great another display function. And this time it is going to take the double as a barometer, so double it is going to return the string. He dot double Hayes cost too Dollar a. Now let's get one last function with the same function name as display on Lesbos mixed barometric This time Indies earned double B and then, let's say double on screen. Forgot. Hint is Goes to gunnery on double Beach Cost. $2 B. Now let me call these functions. Print Ellen. Display less parts when anyone Indies available and since I'm passing, it is a variable with only one perimeter. Then this time it is going to call this function based on the number of parameters sandy type of perimeter. So let's call another function this time this past two para meters as Intesa. So this time it is going to call this function because both of them in teaser and it has to damages. So let's call Boehner Funston This time, let's pass one the one double variable. Now, finally, let's call this display function. So for that we need to pass one in. Teaser on another one is double. So this is called function. Overloading, sore chortling Compiler knows which from center call in the compile time, and based on that information, it will going to call the corresponding false an indie her own time. So let's run this program and you can see in the first case it is actually calling this Swanson in the second case, it is calling this function in the tar case. It is calling this Swanson and one ladies calling this function. So I hope you understood the concept of function overloading on have a captive indie except dessert. 29. 29. Tailrec function in kotlin: Hello, everyone. In this episode, we're going to talk about the Tell Rick function in chortling. Before that, I'm going to talk about the a little bit about records and Fenson off function, they're called itself was called a rickerson frozen. So in this example, I have two functions function mean and rickerson. So whenever we call the recourse and function, it is going to come in here and here. We're actually calling the records and function from this metal again. And this record semester call will going to invoke this function one more time so you can see it is going to Lupin Finally, until or unless it gets some condition Tau terminal, for example, in a really will. Also, if he plays to peddle meters facing each other, then we're going to get the records of emails off in Vigen objects in financially. So you might have noticed this phenomena. So we're going to use the recursive function, you know, to solve those problems which are records have been nater. So recursive function is very useful in order to solve those problems. But because it functions have one serious issue and that is a problem with memory. So it is going to take a lot more space, the resulting in this stack overflow. So let's see this typical issue in our program. So in our hydrophones and Pakis, I have created a file called Tell Rick Dark ITI File and it contends men method only. All right, celestial it started. Now let's write a recursive function, which is going to return the factory lawful number. So function, Let's say factorial and it is going to be after I begin Visa and it is imported from java dot math. And it is also going toe return the big in teaser and let's write return and within two years, the win expressing in here. So when? Unless past this number in here, If this number is a big teaser 0.1, then we're going to return. Begin visa 0.1. So don't be confused with big interested, not one. It is simply who won. So since we're going to use very large into the value, it is not a good idea. Toe stick quit into their plants. So have you begin detail and in else and I'm going to return number and factorial and number minus big in teaser 0.1. And inside this line I'm simply Dick lamenting the number by one. And in our main function, let's say print Ellen on and bacteria. Let's compute the factory love fipe. So if I write five in here, it is going to give us air and sea is expected. I begin Visa. So for that just to begin teaser on and write five. Now let's run this. And here is the factory of five, which is 20. So let's computing factory love 100 this time. So let's run this and it is the factory love 100. Now let's go in here and let's try to compute the factory Love 10,000. So if I run this and we got the air here, so let's see what it says. So that school and it says it's tag over Fallujah. So this is one of the major problem intercourse, a function it is going to cause the racetrack overflow. Now let's try to break down how we caught the struggle over for later. Let's say we want to find the factory love number five, and in this case, our records and function calling will be like this. So first of all, it is going to call the factory five and this federal five. We're going to call the factory for one more time and federal four, it is going to call factual three after Factory one. But if you carefully of job in here, we're actually storing the number is time. The function is called in our step memory. So in our total phones and call, we're starting defied and four in our memory and in our feet function call. We're restoring the 5432 in our struck memory. No, this imagine we have the 10,000 numbers and the function is going to be called for the 10,000 times. So the thing is, when it is true, all those numbers in our district memory and that is the main reason for causing the stroke over four year. So since 22 men is, all those intermediate results are memory stack, it will overflow for last recourse it call, as with us, sign our program. But corpulent supports I special recourse in type called Tell Rick to handle this issue. Now let's see how we can make this normally Carson function as a Children constant so records he finds him to be a tell it Johnson. It needs to satisfy one important condition, and that is the Accorsi call must be the very last call off that method. So let's see this. So in our previous example of factory, we can off the pattern like this. If the number is one, then within Region one, and in the second rule, we're going to compute all the factory function. Example Federal 543 and upto one. And finally, we're going to return the total multiplication. So since in our example, were performing the most because in after a person Records see Call is not the last call here, so it is not eligible for Tell Rick. Now let's see how we can transform this factorial because the matter to the Tell Rick factory. So first of all, we need to make sure that multi biggest in is done before the recourse it call, not offer the record sickle. And the second step is that we need to pass that intimate result as an argument so that we don't need to restore that intimidate result in outer stack memory, and finally, we need to add till modifier to the function Now let's go to the I D and apply all these three steps. So let's get a function called the factory, and this is going to take the number. What is a big in desert and we're going to pass is intimately result as an argument rather than saving into the memory. So our second perimeter will be let's a total value and it is also going to be begin teaser and let's assign the default value as one. And this is going to return the big in dieser. So here, let's do return when and in the when I'm just gonna path e number. And if these number is one, then I'm going to return. Total value on any synergy is going to be one right 100 ways. I'm simply going to say a factorial, and here I'm going to do a number minus big in teaser 0.1. And as the second argument, I'm actually going to pass the multiplication itself rather than a stirring into the memory stack. And finally, any tired till Rick modifier before this function keeper and this is our Children function . So if you notice here, we're force calculating the multiplication and then only we're calling the factory function now. If I come in this now, let's run the same program. No agency. It is not giving any steak over for era, even if we're performing the factory off 10,000. So this is a He was improvement in our program. No elicited wanders off dealer Cronson. The 1st 1 is is there is no risks off its track over four, as the stack does not have to keep Krakoff his intimidated result And the second advantage is we can write our complex program in a recursive manner. But our compiler will transform their complex logic into the farce and every sin low. And in this way, our program will gonna be faster as well. So these are the advantages of telling function. So see you in the next part.