Last active
August 29, 2015 14:23
-
-
Save joanmolinas/8dd62ad0a351104882d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numbers = [Int]() | |
func appendNumbers() { | |
numbers.append(3) | |
//: defer{} is executed in the final on the function | |
//: use defer{} when you want that any code run it always whatever the function result | |
defer {numbers.append(4)} | |
numbers.append(5) | |
} | |
numbers.append(1) | |
numbers.append(2) | |
appendNumbers() | |
numbers.append(6) | |
//OUTPUT | |
numbers -> [1, 2, 3, 5, 4, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment