Better Swift Closures Explained - Swift Tips (2023) - iOS

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2025

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

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

    Lets connect - linkedin.com/in/afrazsiddiqui

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

    Would love to learn more about key paths and other uses, great video!

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

    does the \ is equal to $0 in this syntax?

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

      Not exactly. Its similar short hand but the $ is for capture lists for inbound arguments

    • @3eeka
      @3eeka ปีที่แล้ว

      @@iOSAcademy thanks!

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

    Great tip, learned something new!

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

    Very useful!

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

      Glad you think so!

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

    Great tip! Like the improved readability!

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

      Glad it was helpful!

  • @ronnie-codes
    @ronnie-codes ปีที่แล้ว

    Didn't know these functions took keypaths. That's really great, thanks.

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

    Thanks for your effort, the video is great! The one with computed property is really useful 🙏

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

    I've been going insane lately and with your video I've finally have ......closure! lol

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

    brilliant!
    💡💡💡💡💡💡💡

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

    yeah, I agree - it looks so cool. I kinda wish TypeScript had something similar :p

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

      That would be cool!

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

    Super cool! Thank you!

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

    Thanks Mr. Siddiqui, for discussing this useful topic. Does this mean that KeyPaths by themselves are closures behind the scenes?

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

    so the "\." actually replaces $0 or am I getting it wrong? As there should be the cases when we cant omit $0

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

    Thanks for the closures. They are still difficult for me.

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

      Here is an another closure tutorial: th-cam.com/video/ND44vQ5iJyc/w-d-xo.html

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

      You’re welcome 😊

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

      @@AmitBiswastunebox Thanks!

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

    What if we use 'reduse', how can we handle this approach. Also, isn't it same behavior like $ sign ?

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

    Nice

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

    this is something that a beginner dev will struggle with for months and years and not know there is a solution to the thing that their intuition tells them they should do.

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

    👍👍👍

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

    \ is backslash.

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

    Bitchin )) ❤‍🔥🤘

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

    Good to know about this option! But are the following example the same, or are there any hidden benefits of one or other?
    - .map(\.isValid)
    - .map({$0.isValid })

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

      the latter can also be written as .map { $0.isValid } (except as the very last condition in an "if" or "guard" statement or else a compiler warning will occur).
      benefits of anonymous arguments is that you can negate them: .map { !$0.isValid }
      also one can have multiple anonymous arguments in the closure: .map { !$0.isValid && $1.isPublic }. AND they look better if combined with loops like .forEach { // do something }
      all of which is why i prefer them over key paths.