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
Argument labels have been removed from Swift function types. Instead, they are
9
+
part of the name of a function, subscript, or initializer. Calls to a function
10
+
or initializer, or uses of a subscript, still require argument labels, as they
11
+
always have:
12
+
13
+
```swift
14
+
funcdoSomething(x: Int, y: Int) { }
15
+
doSomething(x: 0, y: 0) // argument labels are required
16
+
```
17
+
18
+
However, unapplied references to functions or initializers no longer carry
19
+
argument labels. For example:
20
+
21
+
```swift
22
+
let f =doSomething(x:y:) // inferred type is now (Int, Int) -> Void
23
+
```
24
+
25
+
Additionally, explicitly-written function types can no longer carry argument
26
+
labels, although one can still provide parameter name for documentation
27
+
purposes using the '_' in the argument label position:
28
+
29
+
```swift
30
+
typealiasCompletionHandler=
31
+
(token: Token, error: Error?) ->Void// error: function types cannot have argument labels
32
+
33
+
typealiasCompletionHandler=
34
+
(_ token: Token, _ error:Error?) ->Void// error: okay: names are for documentation purposes
35
+
```
36
+
6
37
*[SE-0025](https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md): A declaration marked as `private` can now only be accessed within the lexical scope it is declared in (essentially the enclosing curly braces `{}`). A `private` declaration at the top level of a file can be accessed anywhere in that file, as in Swift 2. The access level formerly known as `private` is now called `fileprivate`.
0 commit comments