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.
@@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()
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! 🔥❤️
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.
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
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.
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
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?
but is that mean that apply is thread safe? so if we got an object and we would like to run 3 methods on that object and that object is a global variable so the question is if we use apply those 3 operations will be thread safe?
Try executing that code if some people don't understand what 'let' does number?.let { number = null val num2 = it + 1 } Here 'let' actually saved the global value of number and even in case number becomes null in 'let' block , still 'it' value will remain the same which you defined before
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 !!!
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()
11:04 sick special effects bro
.also {
respect++
}
pow(thanks, 10)
Hi CiF~!
@@johnybaby9574 hi
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
@@phamhung2263 or write a function called "swapValues(x, y)" and use that. That's the most readable.
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
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
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.
Was literally just thinking about finally studying these, and you just uploaded. Thanks!
same wtf
yes, I can read your mind
@@PhilippLackner LOL!
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!
This is the best video on scopes. Thanks
Your videos are very helpful. Your way of teaching is simply awesome.
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
Your tutorials are addictive I watch them repeatedly
Cool, that was pretty much understandable by someone who is new to Kotlin.
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.
even so it was made 4 years ago , it's very useful that i've ever found
Fantastic explanation.
Finally a practically helpful explanation of these scope functions
You explain very clearly. Thank you.
Your tutorials are a big help bro. Thanks!
An absolute psychic. I was going through Kotlin's Documentation and, suffice to say, it confused the fuck outta me.
Thanks for useful explanation. 🙏
Very Well Explained
One of the best explanation. Simple and Easy. Great man
Glad you liked it
Very clear explanation
It is awesome you explains concepts so simple. Hats off
I was waiting for it.you just read my mind
yes, I did
You're the best! Thanks!
Awesome video!You explained very simply and concisely. Thanks a lot Philipp!
Your tutorial are awesome.
Thanks for creating this video.
Simple, crisp explanations ❤
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!
Great explanation
your tutorials are just awesome!
Thanks a ton!
Thank you for the great explanation!
Thanx man this was very helpful 😊
Wow. its so much clear understand. thank you. keep it up.
thank you! , was so easy to understand your explanations
Thank you, I really learn a lot from you
Thanks bro, it is very usefull tutorial. Good luck!
Good explanation for the latest one 😄
Very well explained. Thank you mate.
Really helpful thanks man
just what i was searching for, awesome man
Glad to hear it!
Thank you!! 🤩
You are Great man . Stay blessed
Really informative video.
Thanks a lot
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#
Great!! thanks ❤
Fantastic explanation, thanks a lot.
The best in the world! I am sure!
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
Thank You very much, Sir!)
Thanks. Philipp
Thank you!
So helpful 😎
amazing video mate , keep it up please
Thanks a lot!
so much better than the kotlin udacity explanations
This boi is on another level !
Thanks bro, it's excellent video !
You're welcome!
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!
Schönes Video, gut erklärt 👍
amazing tutorial!!!!!
Thanks!
great vid as usual man
Glad you enjoyed it
crystal clear....
this is awesome
Super helpful
Thanks for this video, Philipp. :)
awesome video bru
Appreciated
Keep it up❤
Thank you, I will
O melhor, muito bom os vídeos.
Amazing just what i wanted after reading the docs and wondering where exactly all these get used
Thank You Bro
No problem
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
Very Good!
i often use 'with 'to declare componen with viewbinding,such as onClickListener, and etc.
Good one 👏👏
Thanks ✌️
With is useful when using string builder. No need to create new variables. Simply call toString at the end
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
Great!
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
lol yo dude the beard! you can definitely make it work but clean is your jam :D tks for the video!
the beard is impressive
Shouldn't it be it++ instead of i++ at 6:19?
thank you.
Welcome!
thanks
Welcome
Thanks for video.. Also i see use function. What is the use function? This is also scoped function
but is that mean that apply is thread safe? so if we got an object and we would like to run 3 methods on that object and that object is a global variable so the question is if we use apply those 3 operations will be thread safe?
what is difference between return@let and simple return in let function
👍🏻👍🏻👍🏻👍🏻👍🏻
This was explained very well. Udemy eat your heart out!😀 Many thanks!
I never realized before that Philipp looks like the Elvis operator ?: ;)
coming from the future and seeing you with beard kinda weird lmao. Anyway, love all your vids
Try executing that code if some people don't understand what 'let' does
number?.let {
number = null
val num2 = it + 1
}
Here 'let' actually saved the global value of number and even in case number becomes null in 'let' block , still 'it' value will remain the same which you defined before
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 !!!
Crisp!
nice