Skip to content

Instantly share code, notes, and snippets.

View agoiabel's full-sized avatar

Agoi Abel Adeyemi agoiabel

View GitHub Profile
lorem lorem
struct Dog {
let name: String
var breed: String
var age: Int
}
class Dog {
let name: String
var breed: String
var age: Int
}
struct Dog {
let name: String
var breed: String
var age: Int
}
//accessing the struct
var myDog = Dog(name: "Molly", breed: "Lhasa Apso", age: 1)
myDog.name //will return Molly
class Dog {
let name: String
var breed: String
var age: Int
init(name: String, breed: String, age: Int) {
self.name = name
self.breed = breed
self.age = age
struct Dog {
let name: String
var breed: String
var age: Int
/** Get the dog details */
func myDogDetail() -> String {
return ("\(self.name) belongs to \(self.breed) and \(self.age)")
}
myDog: Dog = Dog(name: "Molly", breed: "Chichihua", age: 1)
myDog.myDogDetail() //will return:: Molly belongs to Chichihua and 1
struct Dog {
let name: String
var age: Int
var breed: String
}
var dog1 = Dog(name: "Jerry", age: 2, breed: "Poodle")
var dog2 = dog1
dog2.name = "JaneDony"
class Dog {
let name: String
var age: Int
var breed: String
init(name: String, age: Int, breed: String) {
self.name = name
self.age = age
self.breed = breed
}
/** base class **/
class someClass {
}
/** inheritting from someClass **/
class someSubclass: someClass {
//will have access to someClass properties
}