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.
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Download all Swift 2.0 changes as a playground Link to Swift 2.0 changes
Link copied to your pasteboard.