<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 9, 2016, at 11:45 PM, Rien <<a href="mailto:Rien@balancingrock.nl" class="">Rien@balancingrock.nl</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The manual says this:<div class=""><br class=""></div><div class=""><a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html" class="">https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html</a></div><div class=""><br class=""></div><div class=""><i class="">A defer statement is used for executing code just before transferring program control outside of the scope that the defer statement appears in.</i></div><div class=""><br class=""></div><div class="">The scope of a for loop ends when the loop ends.</div></div></div></blockquote></div><br class=""><div class="">Right, more specifically, it is the “static” scope that it is defined in. Go has a similar but different defer statement, which runs defer'd actions at the end of the current dynamic *function* scope. The Swift rules are simpler, more predictable, and are able to be implemented more efficiently.</div><div class=""><br class=""></div><div class="">-Chris</div></body></html>