Ali Mert Güleç
Ali Mert Güleç's Blog

Ali Mert Güleç's Blog

Closures in Swift, SwiftUI.

Ali Mert Güleç's photo
Ali Mert Güleç
·Sep 22, 2022·

1 min read

Closures in Swift, SwiftUI.

- Hello everyone. WELCOME TO THE ANONYMOUS FUNCTION. Today the topic is closures, which are a bit like anonymous functions. I would like to share with you the information I have learned on this subject and the experiences I have gained while learning about this subject. While sharing these, I hope that the article will be useful to you. I am going to try to explain all the information about the ANONYMOUS FUNCTION.

4.png

A Swift closure may or may not return a value. If we want our closure to return some value, we need to mention its return type and use the return statement.

1.png

In addition, I want to mention is shorthand parameter. If one or more of a function’s final parameters are functions, you can use trailing closure syntax. You can also use shorthand parameter names such as $0 and $1, but I would recommend doing that only under the same conditions.

2.png And also we can use closures as parameters when they accept parameters. 3.png In conclusion, This article was the first article I wrote. I chose to share as a method when I learned what I learned. I hope I could be useful to you.

Resources I used to learn the information I shared above:

hackingwithswift.com

docs.swift.org/swift-book/LanguageGuide/Clo..

 
Share this