@@ -10,7 +10,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
10
10
It's now possible to use a default value expression with a generic parameter type
11
11
to default the argument and its type:
12
12
13
- ```
13
+ ``` swift
14
14
func compute <C : Collection >(_ values : C = [0 , 1, 2]) {
15
15
...
16
16
}
@@ -226,7 +226,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
226
226
227
227
* [ SE-0328] [ ] :
228
228
229
- Opaque types (expressed with ' some' ) can now be used in structural positions
229
+ Opaque types (expressed with ` some ` ) can now be used in structural positions
230
230
within a result type, including having multiple opaque types in the same
231
231
result. For example:
232
232
@@ -838,7 +838,7 @@ Swift 5.5
838
838
}
839
839
```
840
840
841
- * The ' lazy' keyword now works in local contexts, making the following valid:
841
+ * The ` lazy ` keyword now works in local contexts, making the following valid:
842
842
843
843
``` swift
844
844
func test (useIt : Bool ) {
@@ -2797,7 +2797,7 @@ Swift 3.0
2797
2797
2798
2798
* [SE- 0101 ][]:
2799
2799
2800
- The functions `sizeof ()`, `strideof ()`, and `alignof ()` have been removed.
2800
+ The functions `sizeof ()`, `strideof ()`, and `alignof ()` have been removed.
2801
2801
Memory layout properties for a type `T` are now spelled
2802
2802
`MemoryLayout < T> .size `, `MemoryLayout < T> .stride `, and
2803
2803
`MemoryLayout < T> .alignment `, respectively.
@@ -2839,7 +2839,7 @@ Swift 3.0
2839
2839
2840
2840
* [SE- 0124 ][]:
2841
2841
2842
- Initializers on `Int ` and `UInt ` that accept an `ObjectIdentifier ` must now use an explicit `bitPattern` label.
2842
+ Initializers on `Int ` and `UInt ` that accept an `ObjectIdentifier ` must now use an explicit `bitPattern` label.
2843
2843
2844
2844
```swift
2845
2845
let x: ObjectIdentifier = ...
@@ -3095,7 +3095,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
3095
3095
didFailToRegisterForRemoteNotificationsWithError error: NSError)
3096
3096
```
3097
3097
3098
- Now it accepts an `Error ` argument:
3098
+ Now it accepts an `Error ` argument:
3099
3099
3100
3100
```swift
3101
3101
optional func application (_ application: UIApplication,
@@ -3318,7 +3318,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
3318
3318
foo/* comment */ ! // no longer works
3319
3319
```
3320
3320
3321
- Parse errors resulting from this change can be resolved by moving the comment outside the expression.
3321
+ Parse errors resulting from this change can be resolved by moving the comment outside the expression.
3322
3322
3323
3323
* [SE- 0031 ][]:
3324
3324
@@ -3379,7 +3379,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
3379
3379
Attributes change from using `= ` in parameters lists
3380
3380
to using `: `, aligning with function call syntax.
3381
3381
3382
- ```
3382
+ ```swift
3383
3383
// before
3384
3384
@available (* , unavailable , renamed="MyRenamedProtocol")
3385
3385
@@ -3420,13 +3420,13 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
3420
3420
3421
3421
Curried function syntax (with successive parenthesized groups of arguments) is removed, and now produces a compile- time error. Use chained functional return types instead.
3422
3422
3423
- ```
3424
- // Before
3425
- public func project (function f: FunctionType)(p0 : CGPoint, p1 : CGPoint)(x : CGFloat) -> CGPoint
3423
+ ```swift
3424
+ // Before
3425
+ public func project (function f: FunctionType)(p0 : CGPoint, p1 : CGPoint)(x : CGFloat) -> CGPoint
3426
3426
3427
- // After
3428
- public func project (function f: FunctionType) -> (p0 : CGPoint, p1 : CGPoint) -> (x : CGFloat) -> CGPoint
3429
- ```
3427
+ // After
3428
+ public func project (function f: FunctionType) -> (p0 : CGPoint, p1 : CGPoint) -> (x : CGFloat) -> CGPoint
3429
+ ```
3430
3430
3431
3431
* Generic signatures can now contain superclass requirements with generic parameter types, for example:
3432
3432
@@ -4773,11 +4773,15 @@ Swift 1.2
4773
4773
* The `@autoclosure ` attribute is now an attribute on a parameter, not an
4774
4774
attribute on the parameter's type.
4775
4775
4776
- Where before you might have used:
4776
+ Where before you might have used
4777
4777
4778
4778
```swift
4779
4779
func assert (predicate : @autoclosure () -> Bool ) {... }
4780
- you now write this as :
4780
+ ```
4781
+
4782
+ you now write this as
4783
+
4784
+ ```swift
4781
4785
func assert (@autoclosure predicate : () -> Bool ) {... }
4782
4786
```
4783
4787
@@ -4819,7 +4823,11 @@ Swift 1.2
4819
4823
// redeclares Objective-C method
4820
4824
// 'setProperty:'
4821
4825
}
4826
+ ```
4827
+
4822
4828
Similar checking applies to accidental overrides in the Objective- C runtime:
4829
+
4830
+ ```swift
4823
4831
class B : NSObject {
4824
4832
func method (arg : String ) { } // note: overridden declaration
4825
4833
// here has type '(String) -> ()'
@@ -4830,7 +4838,11 @@ Swift 1.2
4830
4838
// selector 'method:' has incompatible
4831
4839
// type '([String]) -> ()'
4832
4840
}
4841
+ ```
4842
+
4833
4843
as well as protocol conformances:
4844
+
4845
+ ```swift
4834
4846
class MyDelegate : NSObject, NSURLSessionDelegate {
4835
4847
func URLSession (session : NSURLSession, didBecomeInvalidWithError :
4836
4848
Bool ){ } // error: Objective-C method 'URLSession:didBecomeInvalidWithError:'
@@ -4918,13 +4930,17 @@ Swift 1.2
4918
4930
that used `unsafeBitCast` as a workaround for this issue can be written to
4919
4931
use the raw value initializer.
4920
4932
4921
- For example:
4933
+ For example,
4922
4934
4923
4935
```swift
4924
4936
let animationCurve =
4925
4937
unsafeBitCast (userInfo[UIKeyboardAnimationCurveUserInfoKey].integerValue ,
4926
4938
UIViewAnimationCurve.self )
4927
- can now be written instead as :
4939
+ ```
4940
+
4941
+ can now be written instead as
4942
+
4943
+ ```swift
4928
4944
let animationCurve = UIViewAnimationCurve (rawValue :
4929
4945
userInfo[UIKeyboardAnimationCurveUserInfoKey].integerValue )!
4930
4946
```
0 commit comments