class User { let name: String let age: Int ... } var user = User(name: "Swift", age: 4) user = user(name: user.name, age: user.age + 1)
(edited)// ミュータブルクラス class User { var name: String var age: Int ... } let user = User(name: "Swift", age: 4) user.age += 1 // 楽
(edited)struct
でやると // struct struct User { var name: String var age: Int } var user = User(name: "Swift", age: 4) user.age += 1 // 楽
(edited)