Last active
September 27, 2018 15:14
-
-
Save DominikPetho/e99b8c792a5ceb8e13f42b0b294e8f4a to your computer and use it in GitHub Desktop.
Class-Sample
This file contains hidden or 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 { | |
| var name: String | |
| var surname: String | |
| init(name: String, surname: String) { | |
| self.name = name | |
| self.surname = surname | |
| } | |
| } | |
| let person = Person(name: "Dante", surname: "Brazeal") | |
| //Assign person to another constant | |
| let secondPerson = person | |
| //Change name of second person | |
| secondPerson.name = "Mario" | |
| print(person.name) //Prints "Mario" | |
| print(secondPerson.name) //Prints "Mario" | |
| //They share same instance of person object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment