Skip to main content

Mutability warnings

About 1 minSwiftArticle(s)bloghackingwithswift.comswiftswift-2.0

Mutability warnings 관련

HACKING WITH SWIFT

What's new in Swift?

Mutability warnings | Changes in Swift 2.0

Mutability warnings

Available from Swift 2.0

This is a simple change that is going to go a long way to help code readability. As you know, Swift developers prefer declaring things as constants (using let) rather than variables (using var). But what if you made something a variable by accident? Or if you thought you might need to change it, then never do?

As of Xcode 7 and Swift 2, you'll get warnings in your code whenever you declare variables that never change – Xcode literally examines the way you use the variable and knows if you never change it.

Other changes in Swift 2.0…
Throwing errors | Changes in Swift 2.0

Throwing errors
Use the guard keyword for early returns | Changes in Swift 2.0

Use the guard keyword for early returns
Measure strings using their character count | Changes in Swift 2.0

Measure strings using their character count
Use the defer keyword to delay work until your scope exits | Changes in Swift 2.0

Use the defer keyword to delay work until your scope exits
Checking API availability | Changes in Swift 2.0

Checking API availability

이찬희 (MarkiiimarK)
Never Stop Learning.