Skip to content

Commit f4b241e

Browse files
committed
[Changelog] Add an entry for SE-0326
1 parent 53bdf86 commit f4b241e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0326][]:
9+
10+
It's now possible to infer parameter and result types from the body of a multi-statement
11+
closure. The distinction between single- and multi-statement closures has been removed.
12+
13+
Use of closures becomes less cumbersome by removing the need to constantly specify explicit
14+
closure types which sometimes could be pretty large e.g. when there are multiple parameters
15+
or a complex tuple result type.
16+
17+
For example:
18+
19+
```swift
20+
func map<T>(fn: (Int) -> T) -> T {
21+
return fn(42)
22+
}
23+
24+
func computeResult<U: BinaryInteger>(_: U) -> U { /* processing */ }
25+
26+
let _ = map {
27+
if let $0 < 0 {
28+
// do some processing
29+
}
30+
31+
return computeResult($0)
32+
}
33+
```
34+
35+
The result type of `map` can now be inferred from the body of the trailing closure
36+
passed as an argument.
37+
838
* [SE-0345][]:
939

1040
It is now possible to unwrap optional variables with a shorthand syntax that
@@ -9119,6 +9149,7 @@ Swift 1.0
91199149
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
91209150
[SE-0340]: <https://github.com/apple/swift-evolution/blob/main/proposals/0340-swift-noasync.md>
91219151
[SE-0345]: <https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md>
9152+
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
91229153

91239154
[SR-75]: <https://bugs.swift.org/browse/SR-75>
91249155
[SR-106]: <https://bugs.swift.org/browse/SR-106>

0 commit comments

Comments
 (0)