File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 55
66## Swift 5.9
77
8+ * [ SE-0380] [ ] :
9+
10+ ` if ` and ` switch ` statements may now be used as expressions to:
11+
12+ * Return values from functions, properties, and closures (either with
13+ implicit or explicit ` return ` )
14+ * Throw errors using ` throw `
15+ * Assign values to variables
16+ * Declare variables
17+
18+ Each branch of the ` if ` or ` switch ` must be a single expression, the value
19+ of which becomes the value of the overall expression when that branch is
20+ chosen.
21+
22+ ``` swift
23+ let bullet =
24+ if isRoot && (count == 0 || ! willExpand) { " " }
25+ else if count == 0 { " - " }
26+ else if maxDepth <= 0 { " ▹ " }
27+ else { " ▿ " }
28+ ```
29+
30+ ``` swift
31+ public static func width (_ x : Unicode.Scalar) -> Int {
32+ switch x.value {
33+ case 0 ..< 0x80 : 1
34+ case 0x80 ..< 0x0800 : 2
35+ case 0x0800 ..< 0x1_0000 : 3
36+ default : 4
37+ }
38+ }
39+ ```
40+
841* [ #64927 ] [ ] :
942
1043 Swift 5.9 introduces warnings that catch conversions from an inout
@@ -9732,6 +9765,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
97329765[SE- 0370 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
97339766[SE- 0376 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
97349767[SE- 0377 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md>
9768+ [SE- 0380 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md>
97359769
97369770[#64927 ]: < https: // github.com/apple/swift/issues/64927>
97379771[#42697 ]: < https: // github.com/apple/swift/issues/42697>
You can’t perform that action at this time.
0 commit comments