Map Explained - Kotlin Collections

Поділитися
Вставка
  • Опубліковано 25 лип 2024
  • In this video we talk about the map function that is part of the Kotlin collections library. Using map allows you to transform a collection from one type to another.
    As with every single video I do about software engineering, if you have any questions or comments please let me know below 😊
    🚶‍♂️ FOLLOW ME 🚶‍♂️
    Twitter - / codyengeltweets
    Medium - / codyengel
    📚 RESOURCES 📚
    Learn Kotlin Repository - github.com/CodyEngel/learn-ko...
    Collections Package - github.com/CodyEngel/learn-ko...
    Learn more about Kotlin - kotlinlang.org/
    🎥 CAMERA GEAR 🎥
    Camera - amzn.to/2LM9Zt3
    Microphone - amzn.to/2LLv0Eb
    Lens - amzn.to/317tGPT
    Main Lights - amzn.to/2K2yHDH
    Back Lights - amzn.to/2Yw4HUI
    External Monitor - amzn.to/2YoM2Kl
    * Note: the above links are affiliate links.
    🖥 DESK GEAR 🖥
    Monitor - amzn.to/2yjZPqR
    Headphones - amzn.to/2YBuo68
    Google Nest Hub - amzn.to/30Zuki7
    MacBook Pro 2019 - amzn.to/30YyuXy
    * Note: the above links are affiliate links.

КОМЕНТАРІ • 20

  • @dewetvanrooyen8458
    @dewetvanrooyen8458 3 місяці тому

    Great vid thanks.

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

    Great video, subbed! :)

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

    Almost like table joins in SQL...but with Kotlin code lol.
    Neat and 'modern' way to express things

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

    Awesome

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

    Thanks

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

    Very cool and efficient code, but I think I will stick with good old For Next loop for now just to avoid confusion.

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

      What sort of confusion are you trying to avoid?

  • @pheroqt1238
    @pheroqt1238 4 роки тому

    When we extract an object from another object and throw it into an array list, do you suggest to use double map function or one map + add to empty array list for that?

    • @CodyEngelCodes
      @CodyEngelCodes  4 роки тому

      The map function is available on collections and sequences. Using the map function to add it to a new list is not a great idea since it will break the chain. I’m not quite sure I’m following your use case, if it’s not working from a collection or sequence though I wouldn’t use map at all (it also likely isn’t available as an option).

    • @pheroqt1238
      @pheroqt1238 4 роки тому

      @@CodyEngelCodes I figured out several ways to do it. At last I decided on something like this. If you have a better idea, I would hear :
      val arrayOfData2 = response.data1.children.map {
      it.data2
      }.toList()
      listAdapter.updateList(arrayOfData2)

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

    I’ve a silly doubt , the first map function added to books gives us a book object , which returns authors . Adding map to that should give us an author object instead of list of authors

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

      The collections operators return collections, if we did map followed by first it would give us a single author back. Alternatively if this was done on a sequence instead of a list then it would return one author at a time but you’d still collect that into a list at the end (most likely).

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

    Hi, maybe the example is a little complex to understand for someone that doesn't know what map is.

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

    Hi Cody. I love this video but the example is too complex. Remember people watching are either newbie or have no idea on how to use map

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

    waste of time