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

КОМЕНТАРІ • 177

  • @AlaaAlbrg
    @AlaaAlbrg 3 роки тому +227

    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 роки тому +10

      good!

    • @trungtrankim294
      @trungtrankim294 2 роки тому +1

      Awesome. Thanks a lot man.

    • @rithulraj3348
      @rithulraj3348 Рік тому +1

      *with()* is the combination of *let* and *run* because it does null check also, am I right?

    • @hazfrd
      @hazfrd Рік тому +1

      @@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 роки тому +51

    also is very useful in case x = y.also { y = x } - switch values of variables without third variable

    • @mahdi7236
      @mahdi7236 2 роки тому +1

      big brain time😉

    • @TheMohit987
      @TheMohit987 2 роки тому

      😂😂😂😂 wow

    • @hieuluu2495
      @hieuluu2495 Рік тому

      Awsome

    • @phamhung2263
      @phamhung2263 10 місяців тому

      why don't we just switch those variables with a third variable. It's more readable

  • @codinginflow
    @codinginflow 3 роки тому +62

    11:04 sick special effects bro
    .also {
    respect++
    }

  • @benjaminmorales8624
    @benjaminmorales8624 3 роки тому +12

    You’re an amazing dev, thank you for all this effort and please keep it rocking!

  • @weather120widget8
    @weather120widget8 Рік тому +2

    I really appreciate your teaching style, how you build on topics as you go. Keep up the great work.

  • @ganshakumari5196
    @ganshakumari5196 2 роки тому +2

    Fantastic explanation. Much clearer than most of the online resources, Thanks Mate!

  • @larrystreehouse1124
    @larrystreehouse1124 Рік тому +1

    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

  • @jackli1924
    @jackli1924 Рік тому

    Awesome video!You explained very simply and concisely. Thanks a lot Philipp!

  • @TheMohit987
    @TheMohit987 2 роки тому +1

    Your videos are very helpful. Your way of teaching is simply awesome.

  • @TheMaciak90
    @TheMaciak90 3 роки тому

    Very well explained. Thank you mate.

  • @firuzaaliyeva5382
    @firuzaaliyeva5382 3 роки тому +10

    Was literally just thinking about finally studying these, and you just uploaded. Thanks!

  • @original_anu
    @original_anu 2 роки тому

    Simple, crisp explanations ❤

  • @adarshdev3810
    @adarshdev3810 3 роки тому

    It is awesome you explains concepts so simple. Hats off

  • @damercy
    @damercy 3 роки тому +13

    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! 🔥❤️

  • @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.

  • @FatalRescue
    @FatalRescue 3 роки тому +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!

  • @achalbadgujar9519
    @achalbadgujar9519 3 роки тому

    Finally a practically helpful explanation of these scope functions

  • @ianlipa9826
    @ianlipa9826 7 місяців тому

    Your tutorials are a big help bro. Thanks!

  • @leosvxy
    @leosvxy 2 роки тому

    thank you! , was so easy to understand your explanations

  • @carloscambon5402
    @carloscambon5402 9 місяців тому

    You explain very clearly. Thank you.

  • @ziakhan-tk7rk
    @ziakhan-tk7rk 2 роки тому

    Your tutorials are addictive I watch them repeatedly

  • @EngDesper
    @EngDesper 2 роки тому

    Thank you for the great explanation!

  • @imagetag4618
    @imagetag4618 3 роки тому

    Wow. its so much clear understand. thank you. keep it up.

  • @Alvin-dg9pq
    @Alvin-dg9pq 3 роки тому

    Fantastic explanation, thanks a lot.

  • @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

  • @ramakrishnavjoshi
    @ramakrishnavjoshi 3 роки тому

    Thanks for this video, Philipp. :)

  • @ajaykumarvishwakarma4720
    @ajaykumarvishwakarma4720 2 роки тому

    Really informative video.
    Thanks a lot

  • @rahulchandrabhan
    @rahulchandrabhan 3 роки тому

    One of the best explanation. Simple and Easy. Great man

  • @techmarinar
    @techmarinar 2 роки тому

    Thanx man this was very helpful 😊

  • @mahetachirag8395
    @mahetachirag8395 3 роки тому

    Your tutorial are awesome.

  • @zareahmer5949
    @zareahmer5949 3 роки тому

    You are Great man . Stay blessed

  • @tyrannus00
    @tyrannus00 Рік тому

    Schönes Video, gut erklärt 👍

  • @salimmazariboufares3118
    @salimmazariboufares3118 2 роки тому +1

    Cool, that was pretty much understandable by someone who is new to Kotlin.

  • @yuanyuechen2183
    @yuanyuechen2183 2 роки тому

    Thank you, I really learn a lot from you

  • @yuripanov9670
    @yuripanov9670 2 роки тому

    You're the best! Thanks!

  • @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.

  • @koutheirelbehi4384
    @koutheirelbehi4384 3 роки тому

    This boi is on another level !

  • @lyawileh.a8741
    @lyawileh.a8741 2 роки тому

    Thanks for useful explanation. 🙏

  • @theonlyarjun
    @theonlyarjun 3 роки тому

    just what i was searching for, awesome man

  • @r.j.jeninjoseph4975
    @r.j.jeninjoseph4975 3 роки тому

    Really helpful thanks man

  • @tanishqsehgal2593
    @tanishqsehgal2593 2 роки тому

    Very Well Explained

  • @tomaslopez9999
    @tomaslopez9999 2 роки тому

    Thanks for creating this video.

  • @telurasinmontasik2406
    @telurasinmontasik2406 Рік тому

    Very clear explanation

  • @FreeKnowledge
    @FreeKnowledge 2 роки тому

    Fantastic explanation.

  • @indraj6669
    @indraj6669 3 роки тому

    Great explanation

  • @anvarzaripboyev5730
    @anvarzaripboyev5730 Рік тому

    Thanks bro, it is very usefull tutorial. Good luck!

  • @marinbeslo7841
    @marinbeslo7841 2 роки тому

    your tutorials are just awesome!

  • @aunghtayoo337
    @aunghtayoo337 2 роки тому

    Thanks. Philipp

  • @thearpansircar
    @thearpansircar 3 роки тому +1

    An absolute psychic. I was going through Kotlin's Documentation and, suffice to say, it confused the fuck outta me.

  • @themichael8767
    @themichael8767 Рік тому

    Thank You very much, Sir!)

  • @brucebane7401
    @brucebane7401 3 роки тому

    amazing tutorial!!!!!

  • @user-uu8rn6wf4u
    @user-uu8rn6wf4u Рік тому

    Thank you!! 🤩

  • @mdjahidulislam9205
    @mdjahidulislam9205 3 роки тому +1

    I was waiting for it.you just read my mind

  • @sckly43
    @sckly43 2 роки тому

    awesome video bru

  • @vibinjoby
    @vibinjoby 2 роки тому

    Amazing just what i wanted after reading the docs and wondering where exactly all these get used

  • @mohamadalighezelbashyan4482

    Great!! thanks ❤

  • @RackaApps
    @RackaApps 3 роки тому

    Super helpful

  • @alexnovikov1609
    @alexnovikov1609 Рік тому

    Thank you!

  • @walkmn
    @walkmn 2 роки тому

    Good explanation for the latest one 😄

  • @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#

  • @leonidas_30052
    @leonidas_30052 3 роки тому

    O melhor, muito bom os vídeos.

  • @mohammedelamin1563
    @mohammedelamin1563 3 роки тому

    So helpful 😎

  • @dreamer6228751
    @dreamer6228751 3 роки тому

    Thanks bro, it's excellent video !

  • @DeniizDenizDeniz
    @DeniizDenizDeniz 3 роки тому +1

    How can you dislike this kind of tutorial 4 people? HOW?

  • @andriibibik39
    @andriibibik39 3 роки тому

    Very Good!

  • @imnithish
    @imnithish 3 роки тому

    great vid as usual man

  • @abuiman5251
    @abuiman5251 3 роки тому

    Thanks!

  • @aneessaleh2870
    @aneessaleh2870 3 роки тому +1

    amazing video mate , keep it up please

  • @sudarshanh.s.521
    @sudarshanh.s.521 7 місяців тому

    this is awesome

  • @mehdiparsaei1867
    @mehdiparsaei1867 3 роки тому

    The best in the world! I am sure!

  • @hirarkiardipratamakiki8777
    @hirarkiardipratamakiki8777 3 роки тому

    i often use 'with 'to declare componen with viewbinding,such as onClickListener, and etc.

  • @DreckbobBratpfanne
    @DreckbobBratpfanne 2 роки тому +1

    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

  • @mandroidx1474
    @mandroidx1474 3 роки тому

    Appreciated
    Keep it up❤

  • @jayeshsuthar5590
    @jayeshsuthar5590 3 роки тому

    crystal clear....

  • @shreyashachoudhary480
    @shreyashachoudhary480 Рік тому

    Great!

  • @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

  • @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 роки тому +1

      Not planned right now, but I also don't say I never will. I might do some flutter videos in the next time

  • @fourcade7851
    @fourcade7851 3 роки тому +1

    Thank You Bro

  • @shreyashchoudhary7413
    @shreyashchoudhary7413 3 роки тому

    Epic!

  • @pratikchauhan989
    @pratikchauhan989 3 роки тому

    Good one 👏👏

  • @jeffreyrudolph6334
    @jeffreyrudolph6334 Рік тому

    so much better than the kotlin udacity explanations

  • @highs_and_lows4665
    @highs_and_lows4665 3 роки тому

    This was explained very well. Udemy eat your heart out!😀 Many thanks!

  • @lional4898
    @lional4898 3 роки тому

    With is useful when using string builder. No need to create new variables. Simply call toString at the end

  • @amiribrahim01
    @amiribrahim01 3 роки тому

    thank you.

  • @DeepSingh-wk5ts
    @DeepSingh-wk5ts 3 роки тому

    Thanks

  • @mohammadamirkanjoori138
    @mohammadamirkanjoori138 Рік тому

    nice

  • @soontaek
    @soontaek 3 роки тому

    I left you some feedback on your previous video (Preference Datastore)

  • @serhatkarakoca
    @serhatkarakoca 3 роки тому

    Thanks for video.. Also i see use function. What is the use function? This is also scoped function

  • @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

  • @Nithin_Coorg
    @Nithin_Coorg Рік тому

    Crisp!

  • @erfansn869
    @erfansn869 3 роки тому

    thanks

  • @renaldyhiunarto4369
    @renaldyhiunarto4369 6 місяців тому

    coming from the future and seeing you with beard kinda weird lmao. Anyway, love all your vids

  • @Alchemist10241
    @Alchemist10241 2 роки тому

    This video definitely belongs to 5 percent group according to 95/5 rule (80/20 rule). Great and precise job 🚀

  • @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 !!!

  • @erfansn869
    @erfansn869 3 роки тому

    please create video for coroutines for all function GlobalScoup, withContext, .....

  • @nishantpattani3053
    @nishantpattani3053 3 роки тому

    what is difference between return@let and simple return in let function

  • @vigneshdroid1654
    @vigneshdroid1654 Рік тому

    Hi Bro, Your videos are very helpful for me. You Know Tamil language Bro?.

  • @tejas5331
    @tejas5331 2 роки тому

    Hey can you tell me how to fetch data about places from API and show on Map in Android?

  • @scottbiggs8894
    @scottbiggs8894 10 місяців тому

    I never realized before that Philipp looks like the Elvis operator ?: ;)