When in Kotlin - Difference between If else and when in Kotlin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Inside kotlin, we are learning the details of the conditional statement in big words. Before this we have learned the details of the words of IF ELS ICF, so in this video we will learn the details of the big words of WHEN, here we will compare WHEN and IF ELSE. We will also see and we will see which IFL is suitable relief and who should do it when because so these are both conditional statements and also here we are going to see the concept of range so without wasting i.e. further time we will see this video. Let's start welcome you new era Android up development and now we will become champion of Android Gas me name is Rana Tahir Bilal and your watching Neat Roots lets start computer screen pe you can see here the keyword of one can be seen here So, I have created a file and there is a function inside it, but before that let us understand why we have to do the 'when' because if you see here, even while doing it, we can reduce the condition. We were taking the decision here, follow the mother, there was a condition here, follow the mother, Rahul's height was like Rahul's height, if it is big, we imposed conditions here, then we had checked that Rahul is here. Ola was coming, before this we have also done the work related to voting system, so now we have learned here in the big details of the forest, so gas, first of all let me tell you the syntax of the bank, the syntax will be like this, okay. Yes, the syntax will be something like this, here we can pass whatever variable we have to pass, while checking the variable, whatever condition we check inside, that condition will be checked, you can learn one in detail. So here we take it ahead, we also took the last time ahead, okay so here we take it ahead, took the variable ahead and let's go to mother, here I take 10 ahead, right here let's one. If we are doing it then inside this we will have to get it passed further because we are checking further here, now what I am going to reduce here, you have to fox it, mother, let's see, 18 was ahead here. You can see here only when we were voting and here I will paste it in the same way but here we will have to do it by operator, we will have to do it within the syntax of bank, so remember this. Now, here on the second number, we had the condition, a little ahead on 50, here we check it. Let's close, we will have to put airplane here too and from here, if you want, copy it. From here, I am going to copy this line. I am here and I will get it done here, I will paste it, okay, let us format it a little, I will also make it smaller, you can vote on 50, and after that, you can put as many conditions as you want here. You can put it, 'Mom, I am late by this time', here I am late by 55, here by mom, I am late by 60, here I am late by 70, so here you can see that it is very difficult to read the code. It is becoming easy, now here you can write different things, you can do that, this is the scenario citizen, here we simply checked, now if you want to do this, then write 60 here and write it along with Let's give it 55 because when we get it printed, we should see a little difference, so now here I write 55 because I am checking that this condition becomes true. Now I run it once, wherever you are . See, okay, we can see this, you can boat no, here we are getting to see and this 55 here, that this condition is true here and we are getting to see the same output, but gas, now here you see. That is, here we have to do the work of ELSE, so here you have to do the work of LIC, then we will do it in the same way, okay, that means we will appoint an operator and further, whatever you have to print, you can get it done here, you can do it here. I will tell you why I didn't do it to others. Guys, if you see here, we have to face a problem. Here, we had specifically checked that if the front is less than 40, that means it means 18 and If 40 is in between then your output was A selection on age exit and here inside the else we had checked Aa you can board no because it is above 18 means mother let's come here if above 40 is ahead whose 40 There are red cases from 1 to 100 also, so take the number till 100, then put it forward in the group, this was the output for Bandho, You Can Vote No [Music] Okay, now what do we have to do here, from 1 to 100, all go ahead. For the group, this one condition will have to be imposed here. Okay, so now you must be thinking. Here, as to how to write it, I will simplify it a bit because for this we can convert the concept of range into a range, but not only the function of range, we get it in Colddrin, so simply call it, now we call it range. Now see what the syntax is, did we have to declare a variable here, we have it ready, here we have to take the result, okay yes because the result will be here, I have written the result and also here I have to put a range in the front. Let 's go to mother, here we need counting from one to 100, so take the same mother, we will write here, next will come here and here we will do it together and also here we have to write the range from one to 100, so that is something. In this way we will write, okay, now you can see that the dream is perfect. Now if you look here, you can see that we have simply written 'dod' but this 'le dene equal tu le dene equal tu' has come to us automatically here. Now we can check it properly here, okay and here we write your vote, it is not listed, it is okay because sometimes this problem has also come, the votes of some people are not even listed. Well, here it is 55 A, so this condition was getting true, so we were getting to see this output, now I change it a little bit to 1855, that is, I give something like this value here, which is not available here. Here, let me give 199, okay, so now I run it once, so you can see its output at this place, now you can see your what is it not listed, this is what we are getting to see. Now here you have got the idea of ​​how we can count from one to 100 with the help of range. Come on mother, if you are still facing any problem then you can get the result printed here. Okay, if you get the result printed, people can comment below, your range will be cleared better, I have run it, you can see the project here, we are getting errors, they can see this. We had a useless empty Briseis A. Again if I run this then my problem will be solved. So you can see further we have done the short here, we get it printed, that is, the result is fine, that means we will get this thing printed. You can see that it is in the range of one to 100, so this condition is true. If here we take 55, then here also the condition will remain true. If here we take 100, then also the condition here is true. What will remain of True and Maa, let's say if we take forest here, then here we will see error. Okay, here you are seeing, you are getting to see water. Now here one more, let me tell you, here we until's word when can I do it, okay yes, you can see Antil, I did it, now here I want to write Hundred, so here you will see, okay, now here you can see, there was a dot, then here, the last one. The value of the first one was going to be considered within this range, but until you write dog, the last value will not be considered, so dot is correct, this is for you, now we will convert it to the code given below. You came to know that inside the one which was less, our code is also being reduced, we are getting to see it quite well but it is not very correct in this how because here we have to reduce from if, then we do that in IF ELSE. We can do it, it 's okay because there will be a little code here and after that we had to check the conditions a bit. Come on, mother, the condition is from here till here, so it was not so good in the forest, so what is good in the forest or In which cases it is the best, now let us see its biggest, let us find the max here, let's make it very small, you have to find the value, whatever value it is, if it is the power, okay, then we give the value here. And the value will be something like five daily, copy one here and paste it here, now what are the options that you have here, the first option is as you know, the second option will be there, the third option will be there again, the fourth option will be there, so you Gas here, we write down, we have got one here and below what is G, we have got two and on the third we have got 3, right and below what we need, we have got it by going to mother and the value is here only by doing it. Okay, let me make four which is perfect for me and one on which we put the value above. Now we have to comment this code once again and I run it. You can see this code by getting this If you look at the gas output at some place at this place, then from this you can know that the max one is less here, we have We have done it quite quickly, here we write choose option between 124, if we had to fix it, we [music] here we would have done something less than this, here on the value, let's go to the mother, now here we have checked the value. We had to do IF value equal to one, then we could show whatever output we wanted, meaning we got one, then we had to put LCF and in that we got value equal to 2 and then we got print, then less than three and four . It had to be less than , and you see here the code was also getting very long, but here our code has become very smooth, we have to read less lines of code, but our code has become less. Guys, you have to learn to do If's and One's as per the rules, only then you will become a good programmer, then Gas, by now you have got a proper idea about If's Else One's and Range's, then Gas you all know our new Android up development. Batch is also starting, if you want to join, that is, if you want to take live classes, then you are getting the form inside the description, you simply submit it, then you get only this much money in this video. Next topic in the next video. Till then take care of yourself and keep watching Neat Root
Info
Channel: Neat Roots
Views: 3,142
Rating: undefined out of 5
Keywords: Kotlin programming, When statement in Kotlin, Range in Kotlin, Kotlin coding tutorial, Kotlin for beginners, Kotlin development, Kotlin examples, Kotlin practical applications, Kotlin syntax, Kotlin data types., kotlin programming language tutorial, kotlin if else expression, range expresion in kotln, when expression in kotlin, when expression kotlin, when expression, kotlin if else, kotlin programming language, if else statement, if else in kotlin
Id: ttxQ9Q2-t98
Channel Id: undefined
Length: 11min 49sec (709 seconds)
Published: Sun Mar 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.