Let, Also, Apply, Run, With - Kotlin Scope Functions

  Рет қаралды 94,888

Philipp Lackner

Philipp Lackner

Күн бұрын

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

Пікірлер: 177
@AlaaAlbrg
@AlaaAlbrg 3 жыл бұрын
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.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
good!
@trungtrankim294
@trungtrankim294 2 жыл бұрын
Awesome. Thanks a lot man.
@rithulraj3348
@rithulraj3348 Жыл бұрын
*with()* is the combination of *let* and *run* because it does null check also, am I right?
@hazfrd
@hazfrd Жыл бұрын
@@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
@hazfrd
@hazfrd Жыл бұрын
@@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()
@agp1444
@agp1444 3 жыл бұрын
also is very useful in case x = y.also { y = x } - switch values of variables without third variable
@mahdi7236
@mahdi7236 2 жыл бұрын
big brain time😉
@TheMohit987
@TheMohit987 2 жыл бұрын
😂😂😂😂 wow
@hieuluu2495
@hieuluu2495 Жыл бұрын
Awsome
@phamhung2263
@phamhung2263 11 ай бұрын
why don't we just switch those variables with a third variable. It's more readable
@codinginflow
@codinginflow 3 жыл бұрын
11:04 sick special effects bro .also { respect++ }
@PhilippLackner
@PhilippLackner 3 жыл бұрын
pow(thanks, 10)
@johnybaby9574
@johnybaby9574 3 жыл бұрын
Hi CiF~!
@codinginflow
@codinginflow 3 жыл бұрын
@@johnybaby9574 hi
@benjaminmorales8624
@benjaminmorales8624 3 жыл бұрын
You’re an amazing dev, thank you for all this effort and please keep it rocking!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks, will do!
@ganshakumari5196
@ganshakumari5196 2 жыл бұрын
Fantastic explanation. Much clearer than most of the online resources, Thanks Mate!
@weather120widget8
@weather120widget8 Жыл бұрын
I really appreciate your teaching style, how you build on topics as you go. Keep up the great work.
@larrystreehouse1124
@larrystreehouse1124 Жыл бұрын
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.
@mirzasohailhussain
@mirzasohailhussain 7 ай бұрын
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
@damercy
@damercy 3 жыл бұрын
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! 🔥❤️
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks! You're totally welcome
@achalbadgujar9519
@achalbadgujar9519 3 жыл бұрын
Finally a practically helpful explanation of these scope functions
@FatalRescue
@FatalRescue 3 жыл бұрын
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!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
yes, let > null-check
@TheMohit987
@TheMohit987 2 жыл бұрын
Your videos are very helpful. Your way of teaching is simply awesome.
@usherg4158
@usherg4158 3 жыл бұрын
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.
@firuzaaliyeva5382
@firuzaaliyeva5382 3 жыл бұрын
Was literally just thinking about finally studying these, and you just uploaded. Thanks!
@iJuce
@iJuce 3 жыл бұрын
same wtf
@PhilippLackner
@PhilippLackner 3 жыл бұрын
yes, I can read your mind
@mz-coder
@mz-coder 2 жыл бұрын
@@PhilippLackner LOL!
@jackli1924
@jackli1924 Жыл бұрын
Awesome video!You explained very simply and concisely. Thanks a lot Philipp!
@ziakhan-tk7rk
@ziakhan-tk7rk 2 жыл бұрын
Your tutorials are addictive I watch them repeatedly
@adarshdev3810
@adarshdev3810 3 жыл бұрын
It is awesome you explains concepts so simple. Hats off
@original_anu
@original_anu 2 жыл бұрын
Simple, crisp explanations ❤
@TheMaciak90
@TheMaciak90 3 жыл бұрын
Very well explained. Thank you mate.
@ianlipa9826
@ianlipa9826 8 ай бұрын
Your tutorials are a big help bro. Thanks!
@salimmazariboufares3118
@salimmazariboufares3118 2 жыл бұрын
Cool, that was pretty much understandable by someone who is new to Kotlin.
@Aweklin
@Aweklin 3 жыл бұрын
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
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Awesome, thank you!
@leosvxy
@leosvxy 2 жыл бұрын
thank you! , was so easy to understand your explanations
@carloscambon5402
@carloscambon5402 9 ай бұрын
You explain very clearly. Thank you.
@Alvin-dg9pq
@Alvin-dg9pq 3 жыл бұрын
Fantastic explanation, thanks a lot.
@EngDesper
@EngDesper 2 жыл бұрын
Thank you for the great explanation!
@imagetag4618
@imagetag4618 3 жыл бұрын
Wow. its so much clear understand. thank you. keep it up.
@FreeKnowledge
@FreeKnowledge 2 жыл бұрын
Fantastic explanation.
@ramakrishnavjoshi
@ramakrishnavjoshi 3 жыл бұрын
Thanks for this video, Philipp. :)
@yuanyuechen2183
@yuanyuechen2183 3 жыл бұрын
Thank you, I really learn a lot from you
@koutheirelbehi4384
@koutheirelbehi4384 3 жыл бұрын
This boi is on another level !
@yuripanov9670
@yuripanov9670 2 жыл бұрын
You're the best! Thanks!
@zareahmer5949
@zareahmer5949 3 жыл бұрын
You are Great man . Stay blessed
@bjugdbjk
@bjugdbjk 3 жыл бұрын
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.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thank you!
@thearpansircar
@thearpansircar 3 жыл бұрын
An absolute psychic. I was going through Kotlin's Documentation and, suffice to say, it confused the fuck outta me.
@rahulchandrabhan
@rahulchandrabhan 3 жыл бұрын
One of the best explanation. Simple and Easy. Great man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you liked it
@theonlyarjun
@theonlyarjun 3 жыл бұрын
just what i was searching for, awesome man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad to hear it!
@mahetachirag8395
@mahetachirag8395 3 жыл бұрын
Your tutorial are awesome.
@DeniizDenizDeniz
@DeniizDenizDeniz 3 жыл бұрын
How can you dislike this kind of tutorial 4 people? HOW?
@telurasinmontasik2406
@telurasinmontasik2406 Жыл бұрын
Very clear explanation
@ajaykumarvishwakarma4720
@ajaykumarvishwakarma4720 3 жыл бұрын
Really informative video. Thanks a lot
@tomaslopez9999
@tomaslopez9999 2 жыл бұрын
Thanks for creating this video.
@techmarinar
@techmarinar 2 жыл бұрын
Thanx man this was very helpful 😊
@tyrannus00
@tyrannus00 Жыл бұрын
Schönes Video, gut erklärt 👍
@tanishqsehgal2593
@tanishqsehgal2593 2 жыл бұрын
Very Well Explained
@mdjahidulislam9205
@mdjahidulislam9205 3 жыл бұрын
I was waiting for it.you just read my mind
@PhilippLackner
@PhilippLackner 3 жыл бұрын
yes, I did
@r.j.jeninjoseph4975
@r.j.jeninjoseph4975 3 жыл бұрын
Really helpful thanks man
@lyawileh.a8741
@lyawileh.a8741 2 жыл бұрын
Thanks for useful explanation. 🙏
@sckly43
@sckly43 2 жыл бұрын
awesome video bru
@marinbeslo7841
@marinbeslo7841 2 жыл бұрын
your tutorials are just awesome!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thanks a ton!
@themichael8767
@themichael8767 Жыл бұрын
Thank You very much, Sir!)
@user-uu8rn6wf4u
@user-uu8rn6wf4u Жыл бұрын
Thank you!! 🤩
@anvarzaripboyev5730
@anvarzaripboyev5730 Жыл бұрын
Thanks bro, it is very usefull tutorial. Good luck!
@alexnovikov1609
@alexnovikov1609 Жыл бұрын
Thank you!
@indraj6669
@indraj6669 3 жыл бұрын
Great explanation
@DreckbobBratpfanne
@DreckbobBratpfanne 2 жыл бұрын
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
@aunghtayoo337
@aunghtayoo337 2 жыл бұрын
Thanks. Philipp
@Qrzychu92
@Qrzychu92 2 жыл бұрын
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#
@mohamadalighezelbashyan4482
@mohamadalighezelbashyan4482 Жыл бұрын
Great!! thanks ❤
@brucebane7401
@brucebane7401 3 жыл бұрын
amazing tutorial!!!!!
@RackaApps
@RackaApps 3 жыл бұрын
Super helpful
@vibinjoby
@vibinjoby 2 жыл бұрын
Amazing just what i wanted after reading the docs and wondering where exactly all these get used
@walkmn
@walkmn 2 жыл бұрын
Good explanation for the latest one 😄
@dreamer6228751
@dreamer6228751 3 жыл бұрын
Thanks bro, it's excellent video !
@PhilippLackner
@PhilippLackner 3 жыл бұрын
You're welcome!
@mohammedelamin1563
@mohammedelamin1563 3 жыл бұрын
So helpful 😎
@abuiman5251
@abuiman5251 3 жыл бұрын
Thanks!
@leonidas_30052
@leonidas_30052 3 жыл бұрын
O melhor, muito bom os vídeos.
@imnithish
@imnithish 3 жыл бұрын
great vid as usual man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you enjoyed it
@aneessaleh2870
@aneessaleh2870 3 жыл бұрын
amazing video mate , keep it up please
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks a lot!
@sudarshanh.s.521
@sudarshanh.s.521 7 ай бұрын
this is awesome
@andriibibik39
@andriibibik39 3 жыл бұрын
Very Good!
@jayeshsuthar5590
@jayeshsuthar5590 3 жыл бұрын
crystal clear....
@fourcade7851
@fourcade7851 3 жыл бұрын
Thank You Bro
@PhilippLackner
@PhilippLackner 3 жыл бұрын
No problem
@abdelsttarahmed8821
@abdelsttarahmed8821 3 жыл бұрын
you are legend man i wish seeing you doing a video on Providing offline capabilities with NetworkBoundResource
@PhilippLackner
@PhilippLackner 3 жыл бұрын
I do that in my ktor course on pl-coding.com
@mandroidx1474
@mandroidx1474 3 жыл бұрын
Appreciated Keep it up❤
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thank you, I will
@mehdiparsaei1867
@mehdiparsaei1867 3 жыл бұрын
The best in the world! I am sure!
@shreyashachoudhary480
@shreyashachoudhary480 Жыл бұрын
Great!
@hirarkiardipratamakiki8777
@hirarkiardipratamakiki8777 3 жыл бұрын
i often use 'with 'to declare componen with viewbinding,such as onClickListener, and etc.
@pratikchauhan989
@pratikchauhan989 3 жыл бұрын
Good one 👏👏
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks ✌️
@shreyashchoudhary7413
@shreyashchoudhary7413 3 жыл бұрын
Epic!
@jeffreyrudolph6334
@jeffreyrudolph6334 Жыл бұрын
so much better than the kotlin udacity explanations
@DeepSingh-wk5ts
@DeepSingh-wk5ts 3 жыл бұрын
Thanks
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Welcome
@amiribrahim01
@amiribrahim01 3 жыл бұрын
thank you.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Welcome!
@shidqi100
@shidqi100 3 жыл бұрын
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?
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Not planned right now, but I also don't say I never will. I might do some flutter videos in the next time
@highs_and_lows4665
@highs_and_lows4665 3 жыл бұрын
This was explained very well. Udemy eat your heart out!😀 Many thanks!
@erfansn869
@erfansn869 3 жыл бұрын
thanks
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Welcome
@ankitpareek8979
@ankitpareek8979 Жыл бұрын
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 !!!
@mohammadamirkanjoori138
@mohammadamirkanjoori138 Жыл бұрын
nice
@lional4898
@lional4898 3 жыл бұрын
With is useful when using string builder. No need to create new variables. Simply call toString at the end
@soontaek
@soontaek 3 жыл бұрын
I left you some feedback on your previous video (Preference Datastore)
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks, I saw it! :)
@Nithin_Coorg
@Nithin_Coorg Жыл бұрын
Crisp!
@MrLukasw44
@MrLukasw44 Жыл бұрын
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?
@serhatkarakoca
@serhatkarakoca 3 жыл бұрын
Thanks for video.. Also i see use function. What is the use function? This is also scoped function
@tejas5331
@tejas5331 2 жыл бұрын
Hey can you tell me how to fetch data about places from API and show on Map in Android?
@renaldyhiunarto4369
@renaldyhiunarto4369 6 ай бұрын
coming from the future and seeing you with beard kinda weird lmao. Anyway, love all your vids
@rsobies
@rsobies 2 жыл бұрын
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
@nishantpattani3053
@nishantpattani3053 3 жыл бұрын
what is difference between return@let and simple return in let function
@scottbiggs8894
@scottbiggs8894 10 ай бұрын
I never realized before that Philipp looks like the Elvis operator ?: ;)
@jasperjohnsoncalapini
@jasperjohnsoncalapini 3 жыл бұрын
Can I do something else inside 'apply' and 'run' for example textbox.run { //is this a good practice val x = 10 val squareX = x*x // or maybe some loops text = "$x" } and one more thing, would you prefer 'apply' over 'run' when when modifying views/components in android? Thanks
@PhilippLackner
@PhilippLackner 3 жыл бұрын
no, I would move out of these functions whatever you can move out, this doesn't look very readable to me. If you just modify views and don't care about the return value it doesn't matter if you use apply or run
@Alchemist10241
@Alchemist10241 2 жыл бұрын
This video definitely belongs to 5 percent group according to 95/5 rule (80/20 rule). Great and precise job 🚀
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Рет қаралды 97 М.
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 22 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 27 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 12 МЛН
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 85 М.
Kotlin Scope Functions for Expressiveness: let, run, with, apply
24:51
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
Variance... without Generics!
9:01
Dave Leeds
Рет қаралды 6 М.
Inline Functions: inline, crossinline, and noinline
11:59
Dave Leeds
Рет қаралды 4,2 М.
What is the Context? - Android Basics 2023
11:22
Philipp Lackner
Рет қаралды 52 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 344 М.