Author Topic: Fixing "Variable was never mutated" compiler warning in Swift 2.0  (Read 5697 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Fixing "Variable was never mutated" compiler warning in Swift 2.0
« on: September 11, 2015, 05:04:32 AM »
The Swift 2.0 compiler now checks if the value of a variable will ever be altered. If not, it gives a "Variable was never mutated; consider changing to 'let' constant" warning. Fixing this error is as easy as changing the var keyword to let.

For example:

Code: [Select]
var directory = "test"
Is changed to:

Code: [Select]
let directory = "test"
All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: September 11, 2015, 08:56:06 PM by kjmcneish »