Pergunta de entrevista da empresa Arthrex

What is a capture list and when would you use one?

Resposta da entrevista

Sigiloso

14 de mai. de 2017

If you’re writing Swift, you will have seen this and most likely simply not known the term “capture list” (which would have been my problem if my headhunter didn’t give me a heads up this was likely to be a question). A Swift closure “closes over” values from the local environment (or context) creating a new execution environment for code inside the closure. Objective-C blocks are also examples of closures. While I usually use “weak” (or “weak self”) in a closure, it’s officially better if you Mark an object as “unowned” if the closure and containing object reference each other and will be destroyed at the same time.