Last active
September 27, 2018 15:17
-
-
Save DominikPetho/11be314b8fe653a390984f38b54e2a3e to your computer and use it in GitHub Desktop.
Struct-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
| //Init is automatically created | |
| struct Person { | |
| var name: String | |
| var surname: String | |
| } | |
| let person = Person(name: "Dante", surname: "Brazeal") | |
| //Assign person to another variable. | |
| var secondPerson = person | |
| //Change name of second person | |
| secondPerson.name = "Mario" | |
| print(person) //Prints "Person(name: "Dante", surname: "Brazeal")" | |
| print(secondPerson) //Prints "Person(name: "Mario", surname: "Brazeal")" | |
| //After assigning the property, whole instance of `person` is copied to new instance `secondPerson` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment