Skip to content

Instantly share code, notes, and snippets.

@tranhieutt
Last active July 12, 2017 09:58
Show Gist options
  • Save tranhieutt/cb642f28d7d30642bac1801048e6624f to your computer and use it in GitHub Desktop.
Save tranhieutt/cb642f28d7d30642bac1801048e6624f to your computer and use it in GitHub Desktop.
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