Last active
June 10, 2020 13:39
-
-
Save stevencurtis/b381c0cc08bb6d45dc5eac311cd35301 to your computer and use it in GitHub Desktop.
personfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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