Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol UserProtocol {
- func login()
- func doSomeThing()
- }
- extension UserProtocol {
- func login() {
- print("default login")
- }
- func logout() {
- print("default logout")
- }
- }
- struct Student: UserProtocol {
- let name: String
- let id: Int
- func doSomeThing() {
- //You have to impleted this method because it has no implementation
- }
- // You can override *login* but it is not required and you can use it's default implementation
- // *logout* is also available to use
- func logout() {
- print("**Overriden logout**")
- }
- }
Add Comment
Please, Sign In to add comment