Skip to content

Instantly share code, notes, and snippets.

@thanhluu
Created April 29, 2016 14:14
Show Gist options
  • Save thanhluu/2d402f94841bf1b3635dcae3a52ba69f to your computer and use it in GitHub Desktop.
Save thanhluu/2d402f94841bf1b3635dcae3a52ba69f to your computer and use it in GitHub Desktop.
Bai Tap Struct
struct User {
var fullName: String
var email: String
var age: Int
}
var someUser = User(fullName: "Thanh Luu", email: "[email protected]", age: 27)
var anotherUser = someUser
someUser.email = "[email protected]"
someUser.email
anotherUser.email
class Person {
var fullName: String
var email: String
var age: Int
init(name: String, email: String, age: Int) {
self.fullName = name
self.email = email
self.age = age
}
}
var somePerson = Person(name: "Tim cook", email: "[email protected]", age: 54)
var anotherPerson = somePerson
somePerson.email = "[email protected]"
somePerson.email
anotherPerson.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment