100 Days of Swift – Day 6 (and 7)

Continuation of Hacking With Swift 100 Days of Swift

Day 6 (and 7) – Closures

Closures are a variable containing a function to be executed, for javascript developers this is not a new topic since they do it all the time, but for .Net developers is so…


This content originally appeared on DEV Community and was authored by Davmi Jose Valdez Ogando

Continuation of Hacking With Swift 100 Days of Swift

Day 6 (and 7) - Closures

Closures are a variable containing a function to be executed, for javascript developers this is not a new topic since they do it all the time, but for .Net developers is something almost equivalent to an action.

Writer note:
Is really interesting finding the difference between these languages

A closure in swift looks like this:
`
let myClosure = {
(name: String) in
print("This is the closure I (name) have created")
}

`

Closures can get complicated, since I see how something similar to callback hell can happen. For instance this sounds complicated to read, is complicated to do and just....

"A Closure that accepts a closure with a parameter as a parameter"

Maybe my english is wrong, but as I am still a novice to give more notes about this, I'll just drop this link which works as a base of how powerful (and fragile) working with this type of closures can be, other use case? not sure, but I have to say that implementation of a reduce method just looks so clean.


This content originally appeared on DEV Community and was authored by Davmi Jose Valdez Ogando


Print Share Comment Cite Upload Translate Updates
APA

Davmi Jose Valdez Ogando | Sciencx (2022-04-13T00:32:23+00:00) 100 Days of Swift – Day 6 (and 7). Retrieved from https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/

MLA
" » 100 Days of Swift – Day 6 (and 7)." Davmi Jose Valdez Ogando | Sciencx - Wednesday April 13, 2022, https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/
HARVARD
Davmi Jose Valdez Ogando | Sciencx Wednesday April 13, 2022 » 100 Days of Swift – Day 6 (and 7)., viewed ,<https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/>
VANCOUVER
Davmi Jose Valdez Ogando | Sciencx - » 100 Days of Swift – Day 6 (and 7). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/
CHICAGO
" » 100 Days of Swift – Day 6 (and 7)." Davmi Jose Valdez Ogando | Sciencx - Accessed . https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/
IEEE
" » 100 Days of Swift – Day 6 (and 7)." Davmi Jose Valdez Ogando | Sciencx [Online]. Available: https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/. [Accessed: ]
rf:citation
» 100 Days of Swift – Day 6 (and 7) | Davmi Jose Valdez Ogando | Sciencx | https://www.scien.cx/2022/04/13/100-days-of-swift-day-6-and-7/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.