The defer
statement lets you run code just before the program exits the current scope. This is a great way to dispose of resources or close network connections:
func printMessage() { print("First message") defer { print("Second Message") } print("Third message") } printMessage()
This is what will appear in the console:
First message Third message Second Message
18.116.90.141