Swift Closures Explained

Swift Closures Explained

Sean Allen

1 год назад

59,172 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@DocMacLovin
@DocMacLovin - 01.05.2024 16:47

You are speaking much too fast. A learning viewer needs pace to process your information.

Ответить
@jonathanmartin2326
@jonathanmartin2326 - 22.04.2024 21:27

Before I start this video, I started searching for videos on closures , while actively using “100 days of SwiftUI” lesson plan, but during the first couple lessons involving closures, I could not get out of my head the question “If functions do everything closures do, why then do closures even exist?” So hopefully I get that answer from this video, because this thought it slowing down my ability to progress in learning swift.

Ответить
@bitwisedevs469
@bitwisedevs469 - 13.04.2024 22:44

I am a fan but I think Dr Angela Yu’s course explain it a little better this time.

Ответить
@jadethompson4510
@jadethompson4510 - 22.03.2024 17:31

Was confused AF going through swift tour, but this video really cleared everything up.. thanks!!

Ответить
@Frans000003
@Frans000003 - 10.03.2024 19:22

Hey, very interesting!
Just needed some advice on when should I use a function or computed property with closures?

Ответить
@mostly_def
@mostly_def - 26.02.2024 21:35

Excellent content! This answered so many questions quickly and kindly 👏

Ответить
@pranavsubash689
@pranavsubash689 - 12.02.2024 17:17

Extremely useful video. I came here for closures and learnt so many things I was confused ab all in one go thanks

Ответить
@biganski
@biganski - 12.02.2024 01:15

I should have known that I could trust another Sean to explain this well

Ответить
@raul286162
@raul286162 - 27.01.2024 06:37

As a flutter developer who is learning SwiftUI I must say that it is the most horrible syntax I have seen for such a simple mechanism known in many other languages ​​such as "Callbacks".

Ответить
@RichardBaileyrichoncode
@RichardBaileyrichoncode - 18.01.2024 08:32

Looking for ways to identify closures when we see their address in memory graph during debugging.
So often they just show an address. Is it possible to make a trailing closure more recognizable in mem graph? Or to find a closure by address wile debugging? Or to print the address of a trailing closure?

Ответить
@dixztube
@dixztube - 06.01.2024 02:43

Not a swift dev but some good information here that if you already know this it makes it connect from a different perspective. Great video

Ответить
@Adrian.katzenstein
@Adrian.katzenstein - 11.11.2023 21:09

Hi Sean! I've been working on my programing career for about 2 months now. I'm doing the 100 days of swift with Paul Hudson. Even tho this is all still a bit blurry i do appreciate your content since its starting to clear a bit of the fog that i had. Just wanted to stop by and say thanks! You'll probably see me around a bit more ✌

Ответить
@jrmoulton
@jrmoulton - 01.09.2023 08:51

The video is great! But his definition of a a closure isn't correct. He says that closures are functions that can be passed around. But all functions can be passed around. The real difference between a closure and a function is that a closure has access to variables in the parent scope without needing to pass them in as arguments. This is a Square-Rectangle relationship. All closures are functions but not all functions are closures. What this video shows is that Swift has a short syntax for defining closures that makes them easy to use functions. But the shorthand syntax isn't what makes it a closure. Non-closure functions don't have access to variables in the parent scope unless you pass them in as arguments. Closures can just access variables in the parent scope without having to pass them in as arguments. The examples in this video are good for creating functions with a shorthand syntax that match the function signature but the examples in this video aren't unique to closures.

In Swift all functions are closures. If you define a function (not with closure syntax) in Swift inside of a scope it will have access to variables in the parent scope. This makes it a closure. But this isn't true in all languages and is an implementation detail of the language.

Ответить
@danielniels22
@danielniels22 - 18.08.2023 23:22

best teacher i found about swift fundamentals

Ответить
@jasonmountain4643
@jasonmountain4643 - 16.08.2023 00:59

Finally my Javascript knowledge helps me out. I picked these up quickly.

Ответить
@user-nz5sd3mi8f
@user-nz5sd3mi8f - 03.08.2023 16:34

Excellent explanation, thank you so Much Sean

Ответить
@michaelthompson7217
@michaelthompson7217 - 23.07.2023 12:11

my issue with this video is it isn’t a discussion of closures in swift but a discussion of a syntactic sugar for function pointers.

unless i missed something, there wasn’t any point where you “closed over” or captured the environment when creating the closure, which is an essential part of closures. i assume you can also do this in swift closures but it wasn’t shown here

Ответить
@user-jz7bw9cm3n
@user-jz7bw9cm3n - 11.07.2023 07:07

I absolutely loved the Swift Closures Explained video by Sean Allen. As someone who has struggled to understand closures, this video was a godsend. Sean does an amazing job of breaking down the confusing aspects of closures, like what the parenthesis mean and the shorthand syntax. He explains everything in a clear and concise manner, making it easy for even a beginner like myself to follow along.

I also appreciate the fact that Sean provides a promo code for Squarespace at the beginning of the video. It’s always great to get a discount when you’re starting a new website or domain.

Overall, I highly recommend this video to anyone who is struggling to understand closures, or anyone who wants to brush up on their Swift knowledge. Thank you, Sean, for creating such an informative and helpful video.

Ответить
@allenwaddell556
@allenwaddell556 - 06.07.2023 23:09

I've just started delving into the mystery that is closures. Your video helped both for what they are and, especially, why I will need to know them. Thanks!

Ответить
@armandmugabo1170
@armandmugabo1170 - 10.05.2023 21:22

awesome

Ответить
@rvamerongen
@rvamerongen - 20.04.2023 20:01

A Question, is the var topStudentFilter always recalculated when 1. Its called, or 2.when the student array is changed, or3. at both times.

Ответить
@ingongoyama3995
@ingongoyama3995 - 04.04.2023 06:11

WOW! The most Clear and concise explanation I've seen on closures in 6years of developing.

Ответить
@DavidNitzscheBell
@DavidNitzscheBell - 23.03.2023 18:14

I’m on my phone so not sure if this has been said before but it took me a while to figure out how to sort on multiple values….

Tuples!!!!

{ ($0.score, $0.name) > ($1.score, $1.name) }

This will sort first by descending score, then by descending name.

To sort by DESC score and ASC name:

{ ($0.score, $1.name) > ($1.score, $0.name) }

Ответить
@zurvey
@zurvey - 02.03.2023 20:36

Wow, Sean. You are a very good teacher. Thank you for this. 👍🏼

Ответить
@asherazeem3282
@asherazeem3282 - 18.02.2023 23:34

Most easiest concept in swift is closure

Ответить
@harunroshid4667
@harunroshid4667 - 17.02.2023 18:39

Hi Sean are closures like object in java where you can call them whenever you need them

Ответить
@user-ds3fd6ec4x
@user-ds3fd6ec4x - 12.02.2023 14:29

What a wonderful tutorial, clear but also full of knowledge. You really helped me understand the book of swiftUI, thanks a lot !

Ответить
@joshuahart2100
@joshuahart2100 - 31.01.2023 18:43

Excellent examples! Now do the same example with Async Await

Ответить
@missionsalesforce4646
@missionsalesforce4646 - 31.01.2023 15:22

Can I see a closure as an interface like in Java

Ответить
@wrestlingscience
@wrestlingscience - 31.01.2023 15:08

slow down plz

Ответить
@mzd8184
@mzd8184 - 20.01.2023 14:33

Hey Sean, thanks for this. Can you make a video about Callbacks? Differences between completion handlers and Callbacks?

Ответить
@johndickson9709
@johndickson9709 - 05.01.2023 11:30

Thanks for the great videos, closures have been a source of mystery for me since I started. One question, in the first example, is the closure being passed in as a type for topStudentFilter?

Ответить
@melindamurillo4680
@melindamurillo4680 - 23.12.2022 00:36

“@escaping ? …. Who are we running from?” 😂

Ответить
@hansalucas
@hansalucas - 13.12.2022 12:28

Sean you are without a doubt my number 1 iOS teacher. Thank you.

Ответить
@StuartZiane
@StuartZiane - 12.12.2022 15:37

Well done, great explanations 👍

Ответить
@JeradAcosta9
@JeradAcosta9 - 09.12.2022 22:22

Thank you so much for clearly explaining the $0 and $1 in closures. I have read and studied it so many times but now I just got it in 1 minute.

Thank you!

Ответить
@afixithei.V
@afixithei.V - 05.12.2022 08:51

Should I invest my time in Swift UI or UIkit? I'm an experienced Android developer and just starting to learning iOS development to boost my portfolio; not necessarily trying to get a job as an iOS dev at least for the next 1 - 2 years

Ответить
@farhadali6956
@farhadali6956 - 12.11.2022 16:29

Code magician, expecting more :) with closure and SwiftUI

Ответить
@lancesamaria8130
@lancesamaria8130 - 09.11.2022 02:26

I’m going to be honest with you, this was a G-R-E-A-T explanation. I’ve read so many Medium posts and Stack Overflow answers where people either try to sound too smart or they just don’t realize that they’re not speaking in layman’s terms (they’re speaking to other people who don’t need it explained). This took a very simple approach to something complicated and made it simple. FANTASTIC explanation!!! You do a great job of keeping things simple! Seriously. And I like your graphics!

Ответить
@user-uk1xs6fc5m
@user-uk1xs6fc5m - 07.11.2022 21:25

Super understandable! Thank you for this video, finally i've got it 🤝

Ответить
@frankz2933
@frankz2933 - 04.11.2022 07:26

very good video!

Ответить
@wristocrat
@wristocrat - 04.11.2022 01:59

Thanks!

Ответить
@wristocrat
@wristocrat - 04.11.2022 01:58

I love this!

Ответить
@jaylensmith6308
@jaylensmith6308 - 02.11.2022 08:56

So now think of escaping as you’re putting popcorn in the microwave. But it’s taking so long to pop, you ask that one friend who’s in the kitchen to wait for it to finish popping and bring it back to the living room?

Ответить
@GabeColors
@GabeColors - 01.11.2022 02:35

"empty parentheses and Void are the same thing" - man oh man, this is the kind of stuff that takes hours off the head banging waste of time trying to learn

Ответить
@tylerwatt5651
@tylerwatt5651 - 01.11.2022 01:25

Awesome video, Sean! Thank you for all the work you do!

Ответить