Let, Also, Apply, Run, With - Kotlin Scope Functions
Вставка
- Опубліковано 25 лип 2024
- In this video I will summarize for what you should choose which Kotlin scope function.
00:00 - Kotlin Scope Functions
00:30 - Let
05:10 - Also
07:20 - Apply
09:13 - Run
10:30 - With
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/premium-courses...
💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
elopage.com/s/philipplackner/...
Regular Android tutorials on my Instagram: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
Summary of Scope functions:
let: Used to check nulls, also better than simple null check in multi-threading case
also: same as 'let' but it doesn't return the last line as 'let', instead 'also' will return the object it was called on and 'not the last line!'
apply: helpful function to modify objects, if you want to change in properties of the objects, and it uses 'this' instead of 'it' as we work inside the class of the object
run: equivalent to 'apply', but it won't return the object it was called, instead it will return the last line
with: same as 'run' but a different signature.
good!
Awesome. Thanks a lot man.
*with()* is the combination of *let* and *run* because it does null check also, am I right?
@@rithulraj3348 nope. In fact run is combination of with & let. Run does check nullpointer (let) and reference with this (with) , after that return the last line a.k.a lambda expression
@@rithulraj3348 with() doesn't checking null, just for non-null. in case it is null then use let(), in case you want make some operation while checking null then use run()
also is very useful in case x = y.also { y = x } - switch values of variables without third variable
big brain time😉
😂😂😂😂 wow
Awsome
why don't we just switch those variables with a third variable. It's more readable
11:04 sick special effects bro
.also {
respect++
}
pow(thanks, 10)
Hi CiF~!
@@johnybaby9574 hi
You’re an amazing dev, thank you for all this effort and please keep it rocking!
Thanks, will do!
I really appreciate your teaching style, how you build on topics as you go. Keep up the great work.
Fantastic explanation. Much clearer than most of the online resources, Thanks Mate!
Simple and Concise explanation. Even though I go self-learning with Kotlin for 1 year, this is great to recall my memory and consolidate my knowledge. More importantly, you show us how to teach and explain the basic concept in an interesting and concise passages with live examples.
Thanks Philip, you are sharing so much knowledge without any charge. I have seen so many people share only basics and then member only videos
Awesome video!You explained very simply and concisely. Thanks a lot Philipp!
Your videos are very helpful. Your way of teaching is simply awesome.
Very well explained. Thank you mate.
Was literally just thinking about finally studying these, and you just uploaded. Thanks!
same wtf
yes, I can read your mind
@@PhilippLackner LOL!
Simple, crisp explanations ❤
It is awesome you explains concepts so simple. Hats off
Hey man. I just learnt Kotlin. Previously I've made a few basic projects in android using Java. Fortunately,I found your channel with some really good resources to learn android dev in Kotlin. Just wanted to say a genuine thank you for putting out such great content. Please don't stop. Power to you! 🔥❤️
Thanks! You're totally welcome
o man, I have been reading lots of explanation and still not get it until watching yours. Great example and explanation, thanks for making this video.
Wow, thank you for opening my eyes. I was just using let as shorthand for the null check and did not realize how useful it actually is!
yes, let > null-check
Finally a practically helpful explanation of these scope functions
Your tutorials are a big help bro. Thanks!
thank you! , was so easy to understand your explanations
You explain very clearly. Thank you.
Your tutorials are addictive I watch them repeatedly
Thank you for the great explanation!
Wow. its so much clear understand. thank you. keep it up.
Fantastic explanation, thanks a lot.
I already liked the video before watching because it is the topic I had pinned on my todo list to research this week.
Thanks Philipp
Awesome, thank you!
Thanks for this video, Philipp. :)
Really informative video.
Thanks a lot
One of the best explanation. Simple and Easy. Great man
Glad you liked it
Thanx man this was very helpful 😊
Your tutorial are awesome.
You are Great man . Stay blessed
Schönes Video, gut erklärt 👍
Cool, that was pretty much understandable by someone who is new to Kotlin.
Thank you, I really learn a lot from you
You're the best! Thanks!
Such a fab explanation, Thanks a ton, You should really do a lot more this kind of standalone videos of advanced concepts of Kotlin, it will b super helpful.
Thank you!
This boi is on another level !
Thanks for useful explanation. 🙏
just what i was searching for, awesome man
Glad to hear it!
Really helpful thanks man
Very Well Explained
Thanks for creating this video.
Very clear explanation
Fantastic explanation.
Great explanation
Thanks bro, it is very usefull tutorial. Good luck!
your tutorials are just awesome!
Thanks a ton!
Thanks. Philipp
An absolute psychic. I was going through Kotlin's Documentation and, suffice to say, it confused the fuck outta me.
Thank You very much, Sir!)
amazing tutorial!!!!!
Thank you!! 🤩
I was waiting for it.you just read my mind
yes, I did
awesome video bru
Amazing just what i wanted after reading the docs and wondering where exactly all these get used
Great!! thanks ❤
Super helpful
Thank you!
Good explanation for the latest one 😄
I don't even programm in Kotlin (fellow dotnet dev here!), but this videos are very cool :) I'd love to have this tuff in C#
O melhor, muito bom os vídeos.
So helpful 😎
Thanks bro, it's excellent video !
You're welcome!
How can you dislike this kind of tutorial 4 people? HOW?
Very Good!
great vid as usual man
Glad you enjoyed it
Thanks!
amazing video mate , keep it up please
Thanks a lot!
this is awesome
The best in the world! I am sure!
i often use 'with 'to declare componen with viewbinding,such as onClickListener, and etc.
i liked to use with eg in viewbinding, because then i can avoid typing the binding variable name xD, also you can use multiple of them within each other what is also pretty nifty
Appreciated
Keep it up❤
Thank you, I will
crystal clear....
Great!
you are legend man
i wish seeing you doing a video on Providing offline capabilities with NetworkBoundResource
I do that in my ktor course on pl-coding.com
Great video expected man love your explanation, just asking will you make videos outside topic of android and mobile dev in general ex: Ai, web or desktop?
Not planned right now, but I also don't say I never will. I might do some flutter videos in the next time
Thank You Bro
No problem
Epic!
Good one 👏👏
Thanks ✌️
so much better than the kotlin udacity explanations
This was explained very well. Udemy eat your heart out!😀 Many thanks!
With is useful when using string builder. No need to create new variables. Simply call toString at the end
thank you.
Welcome!
Thanks
Welcome
nice
I left you some feedback on your previous video (Preference Datastore)
Thanks, I saw it! :)
Thanks for video.. Also i see use function. What is the use function? This is also scoped function
in this case number is a property so it is a function. a function can return different results and that's why it is considered as mutuable. inside let block you are dealing directly with a field of the class. 'it' is a field, not a property. so it is immutable
Crisp!
thanks
Welcome
coming from the future and seeing you with beard kinda weird lmao. Anyway, love all your vids
This video definitely belongs to 5 percent group according to 95/5 rule (80/20 rule). Great and precise job 🚀
I have an usecase where i need to call a suspend function(some network call) on completion of it i need to perform other local task. I am trying to use also there but getting unexpected results. Can u explain this !!!
please create video for coroutines for all function GlobalScoup, withContext, .....
what is difference between return@let and simple return in let function
Hi Bro, Your videos are very helpful for me. You Know Tamil language Bro?.
Hey can you tell me how to fetch data about places from API and show on Map in Android?
I never realized before that Philipp looks like the Elvis operator ?: ;)