Guest User

Untitled

a guest
Feb 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. protocol UserProtocol {
  2. func login()
  3. func doSomeThing()
  4. }
  5.  
  6. extension UserProtocol {
  7. func login() {
  8. print("default login")
  9. }
  10.  
  11. func logout() {
  12. print("default logout")
  13. }
  14. }
  15.  
  16. struct Student: UserProtocol {
  17. let name: String
  18. let id: Int
  19.  
  20. func doSomeThing() {
  21. //You have to impleted this method because it has no implementation
  22. }
  23.  
  24. // You can override *login* but it is not required and you can use it's default implementation
  25. // *logout* is also available to use
  26. func logout() {
  27. print("**Overriden logout**")
  28. }
  29. }
Add Comment
Please, Sign In to add comment