Last active
July 12, 2017 09:58
-
-
Save tranhieutt/cb642f28d7d30642bac1801048e6624f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Logger { | |
func printData() { | |
let cars = [ | |
Car(name: "BWM", color: "Green"), | |
Car(name: "Toyota", color: "Blue"), | |
Car(name: "Honda", color: "Black") | |
] | |
cars.forEach { cars in | |
print(car.printDetails()) | |
} | |
} | |
class Car { | |
let name: String | |
let color: String | |
init(name: String, color: String) { | |
self.name = name | |
self.color = color | |
} | |
func printDetails() -> String { | |
return "My car \(name) with \(color) color" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment