Created
April 26, 2023 15:43
-
-
Save MoussaHellal/8e044b8bdf018739ef5067a3b0ac091f to your computer and use it in GitHub Desktop.
value types in swift
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
| struct Book { | |
| var title: String | |
| init(title: String) { | |
| self.title = title | |
| } | |
| } | |
| var bookOne = Book(title: "A Game of Thrones (1996)") | |
| var bookTwo = bookOne // bookTwo now created a new copy from bookOne | |
| bookTwo.title = "A Storm of Swords (2000)" | |
| print(bookOne.title) // Output: "A Game of Thrones (1996)" | |
| print(bookTwo.title) // Output: "A Storm of Swords (2000)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment