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

  Рет қаралды 97,251

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 178
@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 3 жыл бұрын
Awesome. Thanks a lot man.
@rithulraj3348
@rithulraj3348 2 жыл бұрын
*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()
@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
@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 2 жыл бұрын
Awsome
@phamhung2263
@phamhung2263 Жыл бұрын
why don't we just switch those variables with a third variable. It's more readable
@2chotti
@2chotti 7 күн бұрын
This is the best video on scopes. Thanks
@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
@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 3 жыл бұрын
@@PhilippLackner LOL!
@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.
@weather120widget8
@weather120widget8 Жыл бұрын
I really appreciate your teaching style, how you build on topics as you go. Keep up the great work.
@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!
@mirzasohailhussain
@mirzasohailhussain 9 ай бұрын
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
@ganshakumari5196
@ganshakumari5196 2 жыл бұрын
Fantastic explanation. Much clearer than most of the online resources, Thanks Mate!
@ziakhan-tk7rk
@ziakhan-tk7rk 2 жыл бұрын
Your tutorials are addictive I watch them repeatedly
@TheMohit987
@TheMohit987 2 жыл бұрын
Your videos are very helpful. Your way of teaching is simply awesome.
@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
@tanishqsehgal2593
@tanishqsehgal2593 2 жыл бұрын
Very Well Explained
@salimmazariboufares3118
@salimmazariboufares3118 2 жыл бұрын
Cool, that was pretty much understandable by someone who is new to Kotlin.
@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.
@telurasinmontasik2406
@telurasinmontasik2406 Жыл бұрын
Very clear explanation
@thearpansircar
@thearpansircar 3 жыл бұрын
An absolute psychic. I was going through Kotlin's Documentation and, suffice to say, it confused the fuck outta me.
@achalbadgujar9519
@achalbadgujar9519 3 жыл бұрын
Finally a practically helpful explanation of these scope functions
@jeffreyrudolph6334
@jeffreyrudolph6334 Жыл бұрын
so much better than the kotlin udacity explanations
@tomaslopez9999
@tomaslopez9999 2 жыл бұрын
Thanks for creating this video.
@carloscambon5402
@carloscambon5402 11 ай бұрын
You explain very clearly. Thank you.
@ianlipa9826
@ianlipa9826 10 ай бұрын
Your tutorials are a big help bro. Thanks!
@yuripanov9670
@yuripanov9670 3 жыл бұрын
You're the best! Thanks!
@rahulchandrabhan
@rahulchandrabhan 3 жыл бұрын
One of the best explanation. Simple and Easy. Great man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you liked it
@anvarzaripboyev5730
@anvarzaripboyev5730 Жыл бұрын
Thanks bro, it is very usefull tutorial. Good luck!
@FreeKnowledge
@FreeKnowledge 2 жыл бұрын
Fantastic explanation.
@walkmn
@walkmn 2 жыл бұрын
Good explanation for the latest one 😄
@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
@adarshdev3810
@adarshdev3810 3 жыл бұрын
It is awesome you explains concepts so simple. Hats off
@Qrzychu92
@Qrzychu92 3 жыл бұрын
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#
@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!
@mdjahidulislam9205
@mdjahidulislam9205 3 жыл бұрын
I was waiting for it.you just read my mind
@PhilippLackner
@PhilippLackner 3 жыл бұрын
yes, I did
@jackli1924
@jackli1924 Жыл бұрын
Awesome video!You explained very simply and concisely. Thanks a lot Philipp!
@original_anu
@original_anu 3 жыл бұрын
Simple, crisp explanations ❤
@mehdiparsaei1867
@mehdiparsaei1867 3 жыл бұрын
The best in the world! I am sure!
@zareahmer5949
@zareahmer5949 3 жыл бұрын
You are Great man . Stay blessed
@leosvxy
@leosvxy 3 жыл бұрын
thank you! , was so easy to understand your explanations
@imagetag4618
@imagetag4618 3 жыл бұрын
Wow. its so much clear understand. thank you. keep it up.
@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!
@themichael8767
@themichael8767 Жыл бұрын
Thank You very much, Sir!)
@alexnovikov1609
@alexnovikov1609 Жыл бұрын
Thank you!
@yuanyuechen2183
@yuanyuechen2183 3 жыл бұрын
Thank you, I really learn a lot from you
@LittleWasteClub
@LittleWasteClub 2 жыл бұрын
Thank you for the great explanation!
@mahetachirag8395
@mahetachirag8395 3 жыл бұрын
Your tutorial are awesome.
@marinbeslo7841
@marinbeslo7841 3 жыл бұрын
your tutorials are just awesome!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks a ton!
@theonlyarjun
@theonlyarjun 3 жыл бұрын
just what i was searching for, awesome man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad to hear it!
@VeronikaDoma-f5y
@VeronikaDoma-f5y 2 жыл бұрын
Thank you!! 🤩
@TheMaciak90
@TheMaciak90 3 жыл бұрын
Very well explained. Thank you mate.
@lyawileh.a8741
@lyawileh.a8741 2 жыл бұрын
Thanks for useful explanation. 🙏
@mohammedelamin1563
@mohammedelamin1563 3 жыл бұрын
So helpful 😎
@RackaApps
@RackaApps 3 жыл бұрын
Super helpful
@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
@sckly43
@sckly43 3 жыл бұрын
awesome video bru
@techmarinar
@techmarinar 3 жыл бұрын
Thanx man this was very helpful 😊
@mohamadalighezelbashyan4482
@mohamadalighezelbashyan4482 2 жыл бұрын
Great!! thanks ❤
@vibinjoby
@vibinjoby 2 жыл бұрын
Amazing just what i wanted after reading the docs and wondering where exactly all these get used
@abuiman5251
@abuiman5251 3 жыл бұрын
Thanks!
@koutheirelbehi4384
@koutheirelbehi4384 3 жыл бұрын
This boi is on another level !
@Alvin-dg9pq
@Alvin-dg9pq 3 жыл бұрын
Fantastic explanation, thanks a lot.
@indraj6669
@indraj6669 3 жыл бұрын
Great explanation
@r.j.jeninjoseph4975
@r.j.jeninjoseph4975 3 жыл бұрын
Really helpful thanks man
@ajaykumarvishwakarma4720
@ajaykumarvishwakarma4720 3 жыл бұрын
Really informative video. Thanks a lot
@aneessaleh2870
@aneessaleh2870 3 жыл бұрын
amazing video mate , keep it up please
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks a lot!
@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
@sudarshanh.s.521
@sudarshanh.s.521 9 ай бұрын
this is awesome
@hirarkiardipratamakiki8777
@hirarkiardipratamakiki8777 3 жыл бұрын
i often use 'with 'to declare componen with viewbinding,such as onClickListener, and etc.
@lional4898
@lional4898 3 жыл бұрын
With is useful when using string builder. No need to create new variables. Simply call toString at the end
@himanshugoeldelhi
@himanshugoeldelhi 2 жыл бұрын
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
@dreamer6228751
@dreamer6228751 3 жыл бұрын
Thanks bro, it's excellent video !
@PhilippLackner
@PhilippLackner 3 жыл бұрын
You're welcome!
@ramakrishnavjoshi
@ramakrishnavjoshi 3 жыл бұрын
Thanks for this video, Philipp. :)
@imnithish
@imnithish 3 жыл бұрын
great vid as usual man
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you enjoyed it
@tyrannus00
@tyrannus00 Жыл бұрын
Schönes Video, gut erklärt 👍
@Alchemist10241
@Alchemist10241 2 жыл бұрын
This video definitely belongs to 5 percent group according to 95/5 rule (80/20 rule). Great and precise job 🚀
@brucebane7401
@brucebane7401 3 жыл бұрын
amazing tutorial!!!!!
@serhatcd
@serhatcd 3 жыл бұрын
Thanks for video.. Also i see use function. What is the use function? This is also scoped function
@scottbiggs8894
@scottbiggs8894 Жыл бұрын
I never realized before that Philipp looks like the Elvis operator ?: ;)
@riyupapa39
@riyupapa39 2 жыл бұрын
I usually use run like this var a:String?=null //When i want do something if only a is not null, a?.run{ //todo }
@jayeshsuthar5590
@jayeshsuthar5590 3 жыл бұрын
crystal clear....
@highs_and_lows4665
@highs_and_lows4665 3 жыл бұрын
This was explained very well. Udemy eat your heart out!😀 Many thanks!
@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
@shreyashachoudhary480
@shreyashachoudhary480 Жыл бұрын
Great!
@vigneshdroid1654
@vigneshdroid1654 Жыл бұрын
Hi Bro, Your videos are very helpful for me. You Know Tamil language Bro?.
@renaldyhiunarto4369
@renaldyhiunarto4369 8 ай бұрын
coming from the future and seeing you with beard kinda weird lmao. Anyway, love all your vids
@andriibibik39
@andriibibik39 3 жыл бұрын
Very Good!
@ucPhamQuoc
@ucPhamQuoc Жыл бұрын
the beard is impressive
@fourcade7851
@fourcade7851 3 жыл бұрын
Thank You Bro
@PhilippLackner
@PhilippLackner 3 жыл бұрын
No problem
@mandroidx1474
@mandroidx1474 3 жыл бұрын
Appreciated Keep it up❤
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thank you, I will
@coffeedude
@coffeedude 2 жыл бұрын
I learnt that you can use 'also' to swap variables but I don't understand why it works. ie: var foo = "foo" var bar = "bar" foo = bar.also { bar = foo } print(foo + bar) // barfoo
@soontaek
@soontaek 3 жыл бұрын
I left you some feedback on your previous video (Preference Datastore)
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks, I saw it! :)
@shreyashchoudhary7413
@shreyashchoudhary7413 3 жыл бұрын
Epic!
@vikasdaily122
@vikasdaily122 21 күн бұрын
How squaredFunctionI = (i*i) can be a function without return type and body.
@MetehanBOLAT
@MetehanBOLAT 2 жыл бұрын
You said "run" is the same as "with", but "with" is almost the same as "apply" isn't it? Because "with" and "apply" return expected types. run does not return. also { Thank you very much, it was a very informative video by the way. } :)
@cinemovieone
@cinemovieone 3 жыл бұрын
O melhor, muito bom os vídeos.
@pratikchauhan989
@pratikchauhan989 3 жыл бұрын
Good one 👏👏
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks ✌️
@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?
@DeepSingh-wk5ts
@DeepSingh-wk5ts 3 жыл бұрын
Thanks
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Welcome
@satheeshguduri
@satheeshguduri 3 жыл бұрын
If condition null check replaced by let
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 57 МЛН
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 32 МЛН
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 62 МЛН
Kotlin Scope Functions for Expressiveness: let, run, with, apply
24:51
Inline Functions: inline, crossinline, and noinline
11:59
Dave Leeds
Рет қаралды 6 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 87 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 233 М.
10 React Antipatterns to Avoid - Code This, Not That!
8:55
Fireship
Рет қаралды 750 М.
Jobs, Waiting, Cancelation - Kotlin Coroutines
9:32
Philipp Lackner
Рет қаралды 60 М.
WHY IS THE STACK SO FAST?
13:46
Core Dumped
Рет қаралды 157 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26