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.
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 })
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.
Lets connect - linkedin.com/in/afrazsiddiqui
Would love to learn more about key paths and other uses, great video!
More to come!
does the \ is equal to $0 in this syntax?
Not exactly. Its similar short hand but the $ is for capture lists for inbound arguments
@@iOSAcademy thanks!
Great tip, learned something new!
Glad to hear it!
Very useful!
Glad you think so!
Great tip! Like the improved readability!
Glad it was helpful!
Didn't know these functions took keypaths. That's really great, thanks.
Happy to help!
Thanks for your effort, the video is great! The one with computed property is really useful 🙏
So nice of you
I've been going insane lately and with your video I've finally have ......closure! lol
You got this!
brilliant!
💡💡💡💡💡💡💡
Thanks
yeah, I agree - it looks so cool. I kinda wish TypeScript had something similar :p
That would be cool!
Super cool! Thank you!
Thank you too!
Thanks Mr. Siddiqui, for discussing this useful topic. Does this mean that KeyPaths by themselves are closures behind the scenes?
Thanks & no
so the "\." actually replaces $0 or am I getting it wrong? As there should be the cases when we cant omit $0
Thanks for the closures. They are still difficult for me.
Here is an another closure tutorial: th-cam.com/video/ND44vQ5iJyc/w-d-xo.html
You’re welcome 😊
@@AmitBiswastunebox Thanks!
What if we use 'reduse', how can we handle this approach. Also, isn't it same behavior like $ sign ?
Nice
Thanks
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.
Agreed
👍👍👍
Thanks
\ is backslash.
Yep
Bitchin )) ❤🔥🤘
Lol thanks
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 })
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.