Day 56: What’s New With Swift 2.0 , Treehouse Workshop pt 1

Day 56: What’s New with Swift 2.0, Treehouse Workshop pt 1


So, you probably know that Apple announced a new Swift coming this fall, and it comes with some improvements. As always, Treehouse is keeping up and released a workshop on these changes. Swift 2.0 is awesome. I have been pouring through it and I’m loving it. In this post I will only be touching on a couple changes, and will be posting more later covering the rest.

Swift 2.0:

‘println()’ is now ‘print()’

Short, concise, and cleaner. At first it’ll result in all kinds of error messages in your Xcode project, but its one easy fix.

Lets get down to the grit.

Control Flow Construct changes:

Early Exit Using guard:

Use a guard statement to require that a condition must be true in order for the code after the guard statement to be executed.

guard let someVar = /*some expression */ else {

//code to be executed if expression == true


//code to be executed if expression == true


If guard statement’s condition is met, code execution continues after the guard statements closing brace

If that condition is not met, the code inside the else branch is executed.

After executing code in the else branch, use a control transfer statement such as return, break, or continue, or call a function or method that doesn’t return to normal scope.

Repeat While-

This loop performs a single pass through the loop block first, before considering the loop’s condition

“taking place of Do While; Do While has a new purpose”

Do {

//body of loop

} while /*some expression

“if there is a lot of code in body of loop, you can’t see the end, so Repeat addresses this nicely”

repeat {

/*body of loop


} while /*some expression */

There is quite a few more changes and I will be posting them in future posts. This is definitely a fresh reminder to always be willing to learn when working with code. This stuff is always evolving.


Published by: Travis Deaton

I studied International Relations at American University, volunteered for various organizations, and have recently returned from a 5 month tour of our National Parks. Currently an EMT/Wildland Fire & SAR student.

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s