File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,33 @@ Note: This is in reverse chronological order, so newer entries are added to the
3
3
Swift 3.0
4
4
---------
5
5
6
+ * [ SE-0128] ( https://github.com/apple/swift-evolution/blob/master/proposals/0128-unicodescalar-failable-initializer.md )
7
+
8
+ Some UnicodeScalar initializers (ones that are non-failable) now return an Optional,
9
+ i.e., in case a UnicodeScalar can not be constructed, nil is returned.
10
+
11
+ ``` swift
12
+ // Old
13
+ var string = " "
14
+ let codepoint: UInt32 = 55357 // this is invalid
15
+ let ucode = UnicodeScalar (codepoint) // Program crashes at this point.
16
+ string.append (ucode)
17
+ ```
18
+
19
+ After marking the initializer as failable, users can write code like this and the
20
+ program will execute fine even if the codepoint isn't valid.
21
+
22
+ ``` swift
23
+ // New
24
+ var string = " "
25
+ let codepoint: UInt32 = 55357 // this is invalid
26
+ if let ucode = UnicodeScalar (codepoint) {
27
+ string.append (ucode)
28
+ } else {
29
+ // do something else
30
+ }
31
+ ```
32
+
6
33
* [ SE-103] ( https://github.com/apple/swift-evolution/blob/master/proposals/0103-make-noescape-default.md )
7
34
8
35
Closure parameters are non-escaping by default, rather than explicitly being
You can’t perform that action at this time.
0 commit comments