You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,34 @@ CHANGELOG
27
27
Swift 5.3
28
28
----------
29
29
30
+
*[SR-7083][]:
31
+
32
+
Property observers such as `willSet` and `didSet` are now supported on `lazy` properties:
33
+
34
+
```swift
35
+
classC {
36
+
lazyvar property: Int=0 {
37
+
willSet { print("willSet called!") } // Okay
38
+
didSet { print("didSet called!") } // Okay
39
+
}
40
+
}
41
+
```
42
+
43
+
Note that the initial value of the property will be forced and made available as the `oldValue` for the `didSet` observer, if the property hasn't been accessed yet.
44
+
45
+
```swift
46
+
classC {
47
+
lazyvar property: Int=0 {
48
+
didSet { print("Old value: ", oldValue) }
49
+
}
50
+
}
51
+
52
+
let c =C()
53
+
c.property=1// Prints 'Old value: 0'
54
+
```
55
+
56
+
This could have side-effects, for example if the lazy property's initializer is doing other work.
57
+
30
58
*[SR-11700][]:
31
59
32
60
Exclusivity violations within code that computes the `default`
0 commit comments