thieumao

Init change other variable

Mar 11th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.25 KB | None | 0 0
  1. struct Test {
  2.     var first: Double
  3.     var second: Double {
  4.         get {
  5.             return first * 2
  6.         }
  7.         set {
  8.             first = newValue / 2
  9.         }
  10.     }
  11. }
  12.  
  13. var test = Test(first: 30)
  14. test.second
  15. test.second = 90
  16. test.first
Advertisement
Add Comment
Please, Sign In to add comment