On apple website, https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html it states that we can change a variable property in a structure. I am trying to change the person's last name. However I recieve an error at that line of code. Thank you for helping me.
import UIKit
struct people {
let firstName : String
var lastName : String
}
let person = people(firstName: "InitialFirstName", lastName: "InitialLastName")
person.lastName = "ChangedLastName" //<-- error
println(person.firstName)
println(person.lastName)
Error:
Playground execution failed: TestPlayground2.playground:12:17: error: cannot assign to 'lastName' in 'person' person.lastName = "ChangedLastName" ~~~~~~~~~~~~~~~ ^