Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.41 KB | None | 0 0
  1. protocol Proto: class {
  2.  
  3.     var values: [Int] {get set}
  4.  
  5.     func add(value: Int)
  6.     func showValue() -> [Int]
  7. }
  8.  
  9. extension Proto {
  10.     func add(value: Int) {
  11.         values.append(value)
  12.     }
  13.  
  14.     func showValue() -> [Int] {
  15.         return values
  16.     }
  17. }
  18.  
  19. class MyClass: Proto {
  20. //Can we not write this line????
  21.     var values: [Int] = []
  22.  
  23.     func foo() {
  24.         showValue()
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement