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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+19-38Lines changed: 19 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -198,22 +198,15 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
198
198
199
199
*[SE-0025][]:
200
200
201
-
A declaration marked as `private` can now only be accessed within the lexical
202
-
scope it is declared in (essentially the enclosing curly braces `{}`).
203
-
A `private` declaration at the top level of a file can be accessed anywhere
204
-
in that file, as in Swift 2. The access level formerly known as `private` is
205
-
now called `fileprivate`.
201
+
The access level formerly known as `private` is now called `fileprivate`. A Swift 3 declaration marked `private` can no longer be accessed outside its lexical scope (essentially its enclosing curly braces `{}`). A `private` declaration at the top level of a file can be accessed anywhere within the same file, as it could in Swift 2.
206
202
207
203
*[SE-0131][]:
208
204
209
-
The standard library provides a new type `AnyHashable` for use in heterogeneous
210
-
hashed collections. Untyped `NSDictionary` and `NSSet` APIs from Objective-C
211
-
now import as `[AnyHashable: Any]` and `Set<AnyHashable>`.
205
+
The standard library introduces the `AnyHashable` type for use in hashed heterogeneous collections. Untyped `NSDictionary` and `NSSet` Objective-C APIs now import as `[AnyHashable: Any]` and `Set<AnyHashable>`.
212
206
213
207
*[SE-0102][]:
214
208
215
-
The `@noreturn` attribute on function declarations and function types has been
216
-
removed, in favor of an empty `Never` type:
209
+
Swift removes the `@noreturn` attribute on function declarations and replaces the attribute with an empty `Never` type:
217
210
218
211
```swift
219
212
@noreturnfuncfatalError(msg: String) { ... } // old
@@ -225,15 +218,11 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
225
218
226
219
*[SE-0116][]:
227
220
228
-
Objective-C APIs using `id` now import into Swift as `Any` instead of as `AnyObject`.
229
-
Similarly, APIs using untyped `NSArray` and `NSDictionary` import as `[Any]` and
230
-
`[AnyHashable: Any]`, respectively.
221
+
Swift now imports Objective-C `id` APIs as `Any`. In Swift 2, `id` imported as `AnyObject`. Swift also imports untyped `NSArray` and `NSDictionary` as `[Any]` and `[AnyHashable: Any]`, respectively.
231
222
232
223
*[SE-0072][]:
233
224
234
-
Bridging conversions are no longer implicit. The conversion from a Swift value type to
235
-
its corresponding object can be forced with `as`, e.g. `string as NSString`. Any Swift
236
-
value can also be converted to its boxed `id` representation with `as AnyObject`.
225
+
Swift eliminates implicit bridging conversions. Use `as` to force the conversion from a Swift value type to its corresponding object. For example, use `string as NSString`. Use `as AnyObject` to convert a Swift value to its boxed `id` representation.
237
226
238
227
* Collection subtype conversions and dynamic casts now work with protocol types:
239
228
@@ -246,40 +235,36 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a
250
-
prefix and suffix of all strings.
238
+
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.
251
239
252
240
* [SE-0128][]:
253
241
254
-
Some UnicodeScalarinitializers (ones that are non-failable) now return an Optional,
255
-
i.e., incase a UnicodeScalar can not be constructed, nilis returned.
242
+
Some non-failable UnicodeScalar initializers now return an Optional. When a UnicodeScalar cannot be constructed, these initializers returnnil.
256
243
257
244
```swift
258
245
// Old
259
246
var string =""
260
-
let codepoint:UInt32=55357//this is invalid
261
-
let ucode =UnicodeScalar(codepoint) // Program crashes at this point.
247
+
let codepoint:UInt32=55357//Invalid
248
+
let ucode =UnicodeScalar(codepoint) // Program crashes here.
262
249
string.append(ucode)
263
250
```
264
251
265
-
After marking the initializer as failable, users can write code like this
266
-
and the program will execute fine even if the codepoint isn't valid.
252
+
The updated initializers allow users to write code that safely works around invalid codepoints, like this example:
267
253
268
254
```swift
269
255
// New
270
256
var string =""
271
-
let codepoint:UInt32=55357//this is invalid
257
+
let codepoint:UInt32=55357//Invalid
272
258
iflet ucode =UnicodeScalar(codepoint) {
273
-
string.append(ucode)
259
+
string.append(ucode)
274
260
} else {
275
-
// do something else
261
+
// do something else
276
262
}
277
263
```
278
264
279
265
* [SE-0095][]:
280
266
281
-
The `protocol<...>` composition construct has been removed. In its
282
-
place, an infix type operator `&` has been introduced.
267
+
Swift removes the `protocol<...>` composition construct and introduces an infix type operator `&` in its place.
283
268
284
269
```swift
285
270
let a: Foo & Bar
@@ -289,13 +274,11 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
289
274
typealias G = GenericStruct<Foo & Bar>
290
275
```
291
276
292
-
The empty protocol composition, the `Any` type, was previously
293
-
defined as being `protocol<>`. This has been removed from the
294
-
standard library and `Any` is now a keyword with the same behaviour.
277
+
Swift previously defined the empty protocolcomposition (the `Any` type) as `protocol<>`. This definition has been removed from the standard library. The `Any` keyword behavior remains unchanged.
295
278
296
279
* [SE-0091][]:
297
280
298
-
Operators can now be defined within types or extensions thereof. For example:
281
+
Swift permits you to define operators within types or their extensions. For example:
299
282
300
283
```swift
301
284
struct Foo:Equatable {
@@ -307,18 +290,16 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
307
290
}
308
291
```
309
292
310
-
Such operators must be declared as`static` (or, within a class, `class
311
-
final`), and have the same signature as their global counterparts. As part of
312
-
this change, operator requirements declared in protocols must also be
313
-
explicitly declared `static`:
293
+
You must declare these operators as`static` (or, within a class, `class
294
+
final`) and they must use the same signature as their global counterparts. As part of this change, protocol-declared operator requirements must be declared `static` explicitly:
314
295
315
296
```swift
316
297
protocolEquatable {
317
298
staticfunc==(lhs: Self, rhs: Self) ->Bool
318
299
}
319
300
```
320
301
321
-
Note that the type checker performance optimization described by [SE-0091][]
302
+
Note: The type checker performance optimization described by [SE-0091][]
0 commit comments