Getting Started: Introduction to Swift · Lesson 5 ·
Bring some stability to your life with Lets.
All of the code that we write in this section and the others is open source and available here in its entirety: https://github.com/onemonth/one-month-ios
let myNewString = "test value"// myNewString = "new test value" // Error: Cannot assign to 'let' value 'myNewString'
let bob: String
bob = "some value"
// bob = "some other value" // Error: Immutable value 'bob' may only be initialized once
let myConstantArray = ["alfie"]
// myConstantArray.append("scrumptious") // Error: Immutable value of type '[String]' only has mutating members named 'append' [constant array cannot be mutated by append]
// myConstantArray = nil // Error: Cannot assign to 'let' value 'myConstantArray'