Thanks for the excellent video, I learned a lot! Question? I come from JavaScript and I was wondering does Kotlin have High Order Arrays? Examples would be forEach, map, filter, reduce. Or what about arrow functions? I am spoiled with JavaScript and so far I haven't seen other programming languages with these features. Thank you.!!
Yep sure. In general, you should try to minimize the scope of variables as much as possible. If you make doesSmile a member variable (i.e. a property) it will be accessible across all methods in the class. However, we only need it in the constructor as a way to compute the nickname property. So it's better to reduce the visibility of doesSmile to *only* be in the constructor like we do here.
Hi Rahul! Nice video! I was wondering what are your thoughts on the kind of logic that should go into the init{} method. I'm interested in some cases where instances of ViewModels have their init{} performing some sort of communication with repositories. I have a feeling that init{} shouldn't perform such implicit actions (which may also introduce side effects). Do you have any thoughts on it? Again, thanks for the content! Have a good day.
I tried to create the Person class in a separate file. It goes under the resources directory. And I'm not able to import it in my main.kt file. How can I import that kotlin Person.kt file?
@@RahulPandeyrkp Hi Rahul, thanks for the reply. I have created the file by right clicking on the src folder and New File. As I didn't see any option for the Kotlin Class file there. And it goes directly to the test/kotlin folder. But then I relocated it to the src/main/resources folder. also attaching the screenshot. But after your reply I tried and check by right clicking on the other folders. And it gives the kotlin class option on the Kotlin directory and the resources directory only. screenshot: ibb.co/C1r1Hwy
Rahul: Deliberately made it suboptimal...
Me, a suboptimal engineer: Nice
hahaha I thought of you while editing. Was hoping you'd comment 🥰
Your example is so simple and concise. Straight to the point.
Thanks Dan 😍
Awesome. Loved it
Exactly to the point video!
thanks brother
More videos on best practices please! ✨🙌
Coming as part of this series!
Sir, your videos are awesome.
good job Rahul could you made us video about code optimisations fro more clean code ?
Thanks
Thanks for the excellent video, I learned a lot!
Question? I come from JavaScript and I was wondering does Kotlin have High Order Arrays? Examples would be forEach, map, filter, reduce. Or what about arrow functions? I am spoiled with JavaScript and so far I haven't seen other programming languages with these features. Thank you.!!
what if the doesSmile is false
will it throw an error for nickname undefined
Can you do a video on keyboard shortcuts? I do everything the hard way and I would like to be more efficient.
here you go :) ruclips.net/video/HLQUtLbjW98/видео.html
Dude, you're the best.
Hi. Why is doesSmile not the member variable? Could you please elaborate?
Yep sure. In general, you should try to minimize the scope of variables as much as possible. If you make doesSmile a member variable (i.e. a property) it will be accessible across all methods in the class. However, we only need it in the constructor as a way to compute the nickname property. So it's better to reduce the visibility of doesSmile to *only* be in the constructor like we do here.
Hi Rahul! Nice video!
I was wondering what are your thoughts on the kind of logic that should go into the init{} method.
I'm interested in some cases where instances of ViewModels have their init{} performing some sort of communication with repositories. I have a feeling that init{} shouldn't perform such implicit actions (which may also introduce side effects). Do you have any thoughts on it?
Again, thanks for the content! Have a good day.
I agree, ideally we should minimize logic in the constructor, otherwise things like testing become difficult.
If we write the smily code wothout int it still will be working. So whats the purpose of init here i didnt get it?
I tried to create the Person class in a separate file. It goes under the resources directory. And I'm not able to import it in my main.kt file. How can I import that kotlin Person.kt file?
The Person class should go into the src/java folder, not resources. How are you creating the new file?
@@RahulPandeyrkp Hi Rahul, thanks for the reply. I have created the file by right clicking on the src folder and New File. As I didn't see any option for the Kotlin Class file there. And it goes directly to the test/kotlin folder. But then I relocated it to the src/main/resources folder. also attaching the screenshot. But after your reply I tried and check by right clicking on the other folders. And it gives the kotlin class option on the Kotlin directory and the resources directory only.
screenshot: ibb.co/C1r1Hwy
Sir can you teach us how REST API is used in one more fragment plz
I have a COVID tracking app series which shows how to do this in an activity. It should be similar for a fragment