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…

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.


Print Share Comment Cite Upload Translate
APA
Davmi Jose Valdez Ogando | Sciencx (2024-03-29T01:15:17+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 2024-03-29T01:15:17+00:00,<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 2024-03-29T01:15:17+00:00]. 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 2024-03-29T01:15:17+00:00. 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: 2024-03-29T01:15:17+00:00]
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/ | 2024-03-29T01:15:17+00:00
https://github.com/addpipe/simple-recorderjs-demo