Skip to content

Instantly share code, notes, and snippets.

@JarvisTheAvenger
Created August 7, 2021 05:42
Show Gist options
  • Save JarvisTheAvenger/eed7ba8eb9f0e235116d681ce61d13d2 to your computer and use it in GitHub Desktop.
Save JarvisTheAvenger/eed7ba8eb9f0e235116d681ce61d13d2 to your computer and use it in GitHub Desktop.
import Foundation
// Mutating function
// The properties of value types cannot be modified within its instance methods by default.
struct User {
var name : String
var age : Int
var address : String
mutating func updateName(_ newName: String) {
self.name = newName
}
}
let user = User(name: "ajay", age: 12, address: "pune")
user.updateName("rahul")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment