diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a04a84f3ca9a..a06734d3929ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,39 @@ _**Note:** This is in reverse chronological order, so newer entries are added to ## Swift 5.9 +* [SE-0380][]: + + `if` and `switch` statements may now be used as expressions to: + + * Return values from functions, properties, and closures (either with + implicit or explicit `return`) + * Throw errors using `throw` + * Assign values to variables + * Declare variables + + Each branch of the `if` or `switch` must be a single expression, the value + of which becomes the value of the overall expression when that branch is + chosen. + + ```swift + let bullet = + if isRoot && (count == 0 || !willExpand) { "" } + else if count == 0 { "- " } + else if maxDepth <= 0 { "▹ " } + else { "▿ " } + ``` + + ```swift + public static func width(_ x: Unicode.Scalar) -> Int { + switch x.value { + case 0..<0x80: 1 + case 0x80..<0x0800: 2 + case 0x0800..<0x1_0000: 3 + default: 4 + } + } + ``` + * [#64927][]: Swift 5.9 introduces warnings that catch conversions from an inout @@ -9729,6 +9762,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig [SE-0370]: [SE-0376]: [SE-0377]: +[SE-0380]: [#64927]: [#42697]: