GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

Mutability warnings

Available from Swift 2.0

Paul Hudson      @twostraws

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.

Hacking with Swift is sponsored by try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Other changes in Swift 2.0…

Download all Swift 2.0 changes as a playground Link to Swift 2.0 changes

Browse changes in all Swift versions

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.