Skip to content

Instantly share code, notes, and snippets.

@tranhieutt
Created July 12, 2017 03:31
Show Gist options
  • Save tranhieutt/2138a9c40c98a756907e22fe5a0ac400 to your computer and use it in GitHub Desktop.
Save tranhieutt/2138a9c40c98a756907e22fe5a0ac400 to your computer and use it in GitHub Desktop.
Example protocol-extension-generic
//Declare class
class Cat {
var name: String
init(name: String) {
self.name = name
}
}
class Dog {
var name:String
init(name: String) {
self.name = name
}
}
//Protocol: get name
protocol Pet {
var name: String {get} //all pets responds to a name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment