Skip to content

Instantly share code, notes, and snippets.

@MoussaHellal
Created April 26, 2023 15:43
Show Gist options
  • Select an option

  • Save MoussaHellal/8e044b8bdf018739ef5067a3b0ac091f to your computer and use it in GitHub Desktop.

Select an option

Save MoussaHellal/8e044b8bdf018739ef5067a3b0ac091f to your computer and use it in GitHub Desktop.
value types in swift
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