Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active January 19, 2018 06:40
Show Gist options
  • Select an option

  • Save agoiabel/f456c3cc0162c4ce2f6dc272d98d35a7 to your computer and use it in GitHub Desktop.

Select an option

Save agoiabel/f456c3cc0162c4ce2f6dc272d98d35a7 to your computer and use it in GitHub Desktop.
protocol Blendable {
func blend() -> ()
}
class Fruit: Blendable {
var name: String
init(name: String) {
self.name = name
}
func blend() {
print("Almost all friut can be used")
}
}
class Dairy {
var name: String
init(name: String) {
self.name = name
}
}
class Cheese: Dairy {
//we cannot use cheese to make smoothie
//so no blendable protocol implemented
}
class Milk: Dairy, Blendable {
func blend() {
print("Milk is a type of dairy")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment