Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Last active June 10, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/b381c0cc08bb6d45dc5eac311cd35301 to your computer and use it in GitHub Desktop.
Save stevencurtis/b381c0cc08bb6d45dc5eac311cd35301 to your computer and use it in GitHub Desktop.
personfunction
class Person {
private var name: String
var age: Int
init(name: String, age: Int) {
self.name = name
self.age = age
}
func getName() -> String {
return name
}
}
let imani = Person(name: "Imani", age: 45)
imani.age = 46
imani.getName() // "Imani"
imani.name = "Roger" // 'age' is inaccessible due to 'private' protection level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment