Skip to content

Instantly share code, notes, and snippets.

@thanhluu
Created April 29, 2016 14:14
Show Gist options
  • Select an option

  • Save thanhluu/2d402f94841bf1b3635dcae3a52ba69f to your computer and use it in GitHub Desktop.

Select an option

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: "thanhlt90@gmail.com", age: 27)
var anotherUser = someUser
someUser.email = "thanhlt90@joomsolutions.com"
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: "tim.cook@apple.com", age: 54)
var anotherPerson = somePerson
somePerson.email = "tcook@apple.com"
somePerson.email
anotherPerson.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment