Created
July 12, 2017 03:31
-
-
Save tranhieutt/2138a9c40c98a756907e22fe5a0ac400 to your computer and use it in GitHub Desktop.
Example protocol-extension-generic
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
//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