How Do You Write Closures in Swift?

113,029
0
Published 2017-08-30
Closures are used everywhere in Swift and the UIKit APIs that we have access to. Today we'll go through a simple exercise of how to write and apply closures by going through a simple algorithm exercise. This lesson covers how to write filtering functions using closures to make our programs more robust. Have fun.

Instagram Firebase Course
www.letsbuildthatapp.com/course/instagram-firebase

Facebook Group
www.facebook.com/groups/1240636442694543/

iOS Basic Training Course
www.letsbuildthatapp.com/basic-training

Completed Source Code
www.letsbuildthatapp.com/course_video?id=1722

Follow me on Twitter: twitter.com/buildthatapp

All Comments (21)
  • @PedrocaRicardo
    FINALLY someone who made me understand closures, thank you!
  • @antonlebedev2890
    Now I seem to be getting pretty much closer to the point of understanding WHY do we need closures)) Thanks a lot!
  • Eventually someone decided to make closure understandable and easy to use thank you sir !
  • I love these kind of videos, where you explore the code syntax for advanced stuff. Nice and clean, thank you brian!
  • @emindeniz
    Best tutorial for Closures so far. Thank you man.
  • @generalk9947
    I am starting university in a couple weeks and by previously watching ur top quality videos on software engineering u have really inspired me to take this course even more because I now realise the many things you can do as a software engineer especially creating apps and how much you can potentially earn thanks👌🏾
  • @israman30
    Beautiful closure explanation..!! Thank you!
  • @Pedruchito
    Thank you very much for making this tutorial video and, for making it with simple explanations so I can understand it. I love it !!
  • @Noahnrg22
    Another great video, everyday you surprise me with what I can learn, thanks !!
  • @BreatheDigital
    Really needed this! Many thanks! You have yourself a new subscriber.
  • @markdang3379
    Your videos are so helpful. Very clear and informative. Thank you!!!
  • @liminal18
    Thanks paused the video and used a closure to solve some mases in that ios swift game. Was a lot of fun.
  • @jonaseduardo01
    Nice explanation , I've been watching tutorials about this in the last days , I thinks that is a very useful concept
  • @drewster6981
    Brilliant. Really good explanation of closures.
  • @arrinal
    Bro... you save me from understanding closure! Thanks a lot!
  • @kaiseration
    I just tested this code: func filterWithPredicateClosure(closure: (Int) -> Bool, numbers: [Int]) -> [Int]{ let greater = numbers.filter(closure) return greater } filterWithPredicateClosure(closure: { return $0 > 6 }, numbers: [1,2,3,4,5,10]) It successfully run. :D Thanks Brian.