[swift-users] Details of defer statement in Swift

Andrea VEH andrea.veh.73 at gmail.com
Thu Nov 10 01:32:47 CST 2016


Hello,
    From *The Swift Programming Language*, I learn the defer statements
execute in the reverse order that they appear in the program. And when
there are two or more defer statements in a loop(e.g. a for loop), defer
statements execute still in the reverse order that they appear, but in the
loop order that the loop statement executes. Code snippet is here(
https://swiftlang.ng.bluemix.net/#/repl/582421bfdee52b5745935771).
    Early I saw this thread(
https://twitter.com/lexrus/status/796370747849441280) from Twitter, I am
curious about defer statement's execute order. Can you tell more details
about it?

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161110/bc619cc0/attachment.html>


More information about the swift-users mailing list