Skip to content

Instantly share code, notes, and snippets.

@hitendradeveloper
Last active July 14, 2018 06:35
Show Gist options
  • Save hitendradeveloper/9bf74a004b046de6d7898f18869451e1 to your computer and use it in GitHub Desktop.
Save hitendradeveloper/9bf74a004b046de6d7898f18869451e1 to your computer and use it in GitHub Desktop.
Protocol Example - 2 : Medium blog
import Foundation
protocol Displayable {
func displayName()
}
class Person {
var name: String
init(name: String) {
self.name = name
}
}
extension Person: Displayable {
func displayName(){
print("I am \(self.name).")
}
}
//How to use? (playground)
let iOSDev = Person(name: "Hitendra iDev")
iOSDev.displayName() //This will display "I am Hitendra iDev"
@hitendradeveloper
Copy link
Author

This is just a simple protocol and class example for the medium blog - Protocol - The power of Swift

https://medium.com/p/950c85bb69b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment