This file contains 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
lorem lorem |
This file contains 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 Dog { | |
let name: String | |
var breed: String | |
var age: Int | |
} |
This file contains 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
class Dog { | |
let name: String | |
var breed: String | |
var age: Int | |
} |
This file contains 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 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 |
This file contains 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
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 |
This file contains 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 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)") | |
} |
This file contains 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
myDog: Dog = Dog(name: "Molly", breed: "Chichihua", age: 1) | |
myDog.myDogDetail() //will return:: Molly belongs to Chichihua and 1 |
This file contains 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 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" |
This file contains 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
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 | |
} |
This file contains 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
/** base class **/ | |
class someClass { | |
} | |
/** inheritting from someClass **/ | |
class someSubclass: someClass { | |
//will have access to someClass properties | |
} |
OlderNewer