Filter, Map, Reduce, CompactMap, FlatMap - Swift - iOS Dev Interview Questions

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 2024
  • Go to squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
    Explaining Filter, Map and Reduce in Swift is a very common iOS Dev interview question. In this tutorial I'll walk you through how Filter, Map and Reduce work and how to chain them together for more complex examples. I also show you how compact map and flat map work.
    This tutorial was created using Xcode 14 and iOS 16.
    iOS Developer Interview Questions Playlist:
    • Swift Interview Tips
    My iOS Dev Courses:
    seanallen.teachable.com/
    My Closures Video:
    • Swift Closures Explained
    Twitter:
    Sean Allen - / seanallen_dev
    Hired.com:
    hired.com/x/1n01g
    Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
    Paul Hudson's Hacking With Swift:
    gumroad.com/a/762098803
    Donny Wals - Combine:
    gumroad.com/a/909014131
    Mark Moeyken’s SwiftUI Books:
    www.bigmountainstudio.com/swiftui-views-book/fzc51
    Objc.io Books (Thinking in SwiftUI & Advanced Swift):
    gumroad.com/a/656585843
    #swift #softwaredeveloper #iosdeveloper
    Timestamps:
    0:00 - Filter, Map, Reduce
    0:45 - Filter
    3:02 - Map
    4:35 - Reduce (simple)
    6:05 - Reduce (on property)
    7:17 - Chaining
    10:18 - Compact Map
    11:21 - Flat Map
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 35

  • @DaveDDD
    @DaveDDD ปีที่แล้ว +4

    The way you explained trailing closures in this made something finally click in my brain! I have no idea how it was able to confuse me for so long - it’s just so simple. Thank you!

    • @seanallen
      @seanallen  ปีที่แล้ว +3

      I remember that feeling! Happy to help.

  • @iLoveAppl3947
    @iLoveAppl3947 4 หลายเดือนก่อน +1

    Finally this video clicked for me... Simple examples makes you understand... i have watched 3 other videos across TH-cam to understand high order functions but they had stupid azz examples i couldn't understand a freking thing...

    • @seanallen
      @seanallen  4 หลายเดือนก่อน

      Glad it finally clicked!

  • @kdtechniquesofficial6153
    @kdtechniquesofficial6153 ปีที่แล้ว

    Never knew about a reduce, just learned it today. Thanks, sean. I've been doing it the hard way all this time.

  • @tylerwatt5651
    @tylerwatt5651 ปีที่แล้ว

    Thank you so much for putting this together! Especially for map and reduce!

  • @ellen_kapii
    @ellen_kapii ปีที่แล้ว +2

    Excellent explanation, as usual. Thank you!

  • @gakkieNL
    @gakkieNL ปีที่แล้ว +2

    You can use keypaths with these high level functions. Makes for great readability!

  • @milanfdl1968
    @milanfdl1968 ปีที่แล้ว

    Cool video. Learned some new things today. Thank you!

  • @mahmoudhashim3720
    @mahmoudhashim3720 11 หลายเดือนก่อน

    Big Love Sean, THANK YOU, you and Afraz are the best

  • @bosch5053
    @bosch5053 ปีที่แล้ว +1

    Thanks

  • @ANILAVCI
    @ANILAVCI ปีที่แล้ว

    Thanks for the shares. You have many followers from Turkey. Even though I watch with automatic subtitles, I learn a lot.

  • @soheilpakgohar6630
    @soheilpakgohar6630 ปีที่แล้ว

    Great job Sean, before this I really got stuck which one is

  • @JasonMitchellAZ
    @JasonMitchellAZ ปีที่แล้ว

    Great explanations for these

  • @Rayana_rei
    @Rayana_rei 11 หลายเดือนก่อน

    smart explanation, clear language! very efficient.. very.. ! 👏🏻

  • @viniciushenriquepellegrini3534
    @viniciushenriquepellegrini3534 8 หลายเดือนก่อน +1

    Amazing !

  • @paulcristo
    @paulcristo 5 หลายเดือนก่อน +1

    Thanks.

    • @seanallen
      @seanallen  5 หลายเดือนก่อน

      Happy to help!

  • @Patrick462
    @Patrick462 ปีที่แล้ว +1

    Great explanations, really appreciate it.
    A few reactions if you're open to such things:
    1. Using Double for currency values will work 99.99% of the time. It's that .01% that will drive you crazy.
    2. I wouldn't use the for loop as a tool to explain filter/map/reduce. Your original explanation is great and more than sufficient. Adding discussion of the for loop way of calculating will confuse a certain percent of viewers, and slow down almost everyone.

    • @mario_luis_dev
      @mario_luis_dev ปีที่แล้ว +1

      I disagree. He’s right in bringing up the for loop for comparisons, since that is the whole point on declarative programming: streamline the uglier, more verbose imperative style

  • @filipecanzi
    @filipecanzi ปีที่แล้ว

    Thanks Sean!!

  • @MegaOlzo
    @MegaOlzo ปีที่แล้ว

    Thanks!)

  • @efecetin5351
    @efecetin5351 ปีที่แล้ว +1

    You are amazing!

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      I appreciate the kind words :)

  • @ahmednemo5954
    @ahmednemo5954 ปีที่แล้ว +1

    Amazing you are the best,Thanks for being one of the best is swift 👍

    • @seanallen
      @seanallen  ปีที่แล้ว

      Thanks for the kind words, Ahmed.

  • @xfabiosoft
    @xfabiosoft ปีที่แล้ว

    How about Zip? How does it work and when is useful?

  • @filipchwastowski4228
    @filipchwastowski4228 ปีที่แล้ว +2

    cool vid, but I believe that $0 and $1 when reducing does not refer to "this and next iteration", but to "current result and current iteration" - isn't that right? :) because here you keep handling constantly "accumulating current result" with each collection's element.

    • @Jacob-rm7vo
      @Jacob-rm7vo ปีที่แล้ว +1

      Yes that is how I understood reduce, even in other languages. It would accumulate - add the first and second, then add the third to that value. I think of $0 meaning lhs (left hand side) and $1 rhs

    • @joshuascorca550
      @joshuascorca550 ปีที่แล้ว

      @@Jacob-rm7vo exactly. Filter iterates through the array, doing this:
      sumSoFar += object.numberToAdd
      So $0 is the lhs, and $1 is the object on the rhs. This is why Sean needs to write $1.users and not $0.users. $0 is an Int already.

  • @mkhasson97
    @mkhasson97 ปีที่แล้ว

    Awesome 🎉
    Is there any plan for portfolio review? I’d love to hear your opinion about my website.
    Thank you in advance 😊

  • @victorriurean
    @victorriurean ปีที่แล้ว

    nice

  • @guitaripod
    @guitaripod ปีที่แล้ว

    69th like

  • @tigran.zakaryan
    @tigran.zakaryan ปีที่แล้ว

    thank you!