@@ -206,9 +206,9 @@ TODO TR: Is there any more detail about this case?
206
206
表明声明已被重命名。
207
207
208
208
``` swift
209
- // First release
209
+ // 首个版本
210
210
protocol MyProtocol {
211
- // protocol definition
211
+ // 协议定义
212
212
}
213
213
```
214
214
@@ -225,9 +225,9 @@ TODO TR: Is there any more detail about this case?
225
225
-->
226
226
227
227
``` swift
228
- // Subsequent release renames MyProtocol
228
+ // 后续版本将 MyProtocol 重命名为 MyRenamedProtocol
229
229
protocol MyRenamedProtocol {
230
- // protocol definition
230
+ // 协议定义
231
231
}
232
232
233
233
@available (* , unavailable , renamed : " MyRenamedProtocol" )
@@ -411,14 +411,14 @@ struct TelephoneExchange {
411
411
412
412
let dial = TelephoneExchange ()
413
413
414
- // Use a dynamic method call.
414
+ // 使用动态方法调用
415
415
dial (4 , 1 , 1 )
416
- // Prints "Get Swift help on forums.swift.org"
416
+ // 打印 "Get Swift help on forums.swift.org"
417
417
418
418
dial (8 , 6 , 7 , 5 , 3 , 0 , 9 )
419
- // Prints "Unrecognized number"
419
+ // 打印 "Unrecognized number"
420
420
421
- // Call the underlying method directly.
421
+ // 直接调用内部的方法
422
422
dial.dynamicallyCall (withArguments : [4 , 1 , 1 ])
423
423
```
424
424
@@ -589,15 +589,16 @@ struct DynamicStruct {
589
589
}
590
590
let s = DynamicStruct ()
591
591
592
- // Use dynamic member lookup.
592
+ // 使用动态成员查询
593
593
let dynamic = s.someDynamicMember
594
594
print (dynamic )
595
- // Prints "325"
595
+ // 打印 "325"
596
596
597
- // Call the underlying subscript directly.
597
+ // 直接调用底层下标
598
598
let equivalent = s[dynamicMember : " someDynamicMember" ]
599
599
print (dynamic == equivalent)
600
- // Prints "true"
600
+ // 打印 "true"
601
+
601
602
```
602
603
603
604
<!--
@@ -910,9 +911,10 @@ https://github.com/apple/swift/blob/main/stdlib/public/core/Macros.swift#L102
910
911
@main
911
912
struct MyTopLevel {
912
913
static func main () {
913
- // Top-level code goes here
914
+ // 顶层代码在此处编写
914
915
}
915
916
}
917
+
916
918
```
917
919
918
920
<!--
@@ -1109,7 +1111,7 @@ Objective-C 代码,名称为 `isEnabled`,
1109
1111
class ExampleClass : NSObject {
1110
1112
@objc var enabled: Bool {
1111
1113
@objc (isEnabled ) get {
1112
- // Return the appropriate value
1114
+ // 返回适当的值
1113
1115
}
1114
1116
}
1115
1117
}
@@ -1307,13 +1309,13 @@ struct SomeWrapper {
1307
1309
}
1308
1310
1309
1311
struct SomeStruct {
1310
- // Uses init()
1312
+ // 使用 init()
1311
1313
@SomeWrapper var a: Int
1312
1314
1313
- // Uses init(wrappedValue:)
1315
+ // 使用 init(wrappedValue:)
1314
1316
@SomeWrapper var b = 10
1315
1317
1316
- // Both use init(wrappedValue:custom:)
1318
+ // 二者都使用 init(wrappedValue:custom:)
1317
1319
@SomeWrapper (custom: 98.7 ) var c = 30
1318
1320
@SomeWrapper (wrappedValue: 30 , custom: 98.7 ) var d
1319
1321
}
@@ -1400,9 +1402,9 @@ struct SomeStruct {
1400
1402
@WrapperWithProjection var x = 123
1401
1403
}
1402
1404
let s = SomeStruct ()
1403
- s.x // Int value
1404
- s.$x // SomeProjection value
1405
- s.$x.wrapper // WrapperWithProjection value
1405
+ s.x // Int 类型的值
1406
+ s.$x // SomeProjection 类型的值
1407
+ s.$x.wrapper // WrapperWithProjection 类型的值
1406
1408
```
1407
1409
1408
1410
<!--
@@ -1672,14 +1674,15 @@ struct ArrayBuilder {
1672
1674
init (_ content : String ) { self .content = content }
1673
1675
func draw () -> String { return content }
1674
1676
}
1677
+
1675
1678
@DrawingBuilder var brokenDrawing: Drawable {
1676
1679
if #available (macOS 99 , * ) {
1677
- FutureText (" Inside.future" ) // Problem
1680
+ FutureText (" Inside.future" ) // 问题所在
1678
1681
} else {
1679
1682
Text (" Inside.present" )
1680
1683
}
1681
1684
}
1682
- // The type of brokenDrawing is Line<DrawEither<Line<FutureText>, Line<Text>>>
1685
+ // brokenDrawing 的类型是 Line<DrawEither<Line<FutureText>, Line<Text>>>
1683
1686
```
1684
1687
1685
1688
<!-- Comment block with swifttest for the code listing above is after the end of this bulleted list, due to tooling limitations. -->
@@ -1714,7 +1717,7 @@ struct ArrayBuilder {
1714
1717
Text (" Inside.present" )
1715
1718
}
1716
1719
}
1717
- // The type of typeErasedDrawing is Line<DrawEither<AnyDrawable, Line<Text>>>
1720
+ // typeErasedDrawing 的类型是 Line<DrawEither<AnyDrawable, Line<Text>>>
1718
1721
```
1719
1722
1720
1723
<!-- Comment block with swifttest for the code listing above is after the end of this bulleted list, due to tooling limitations. -->
0 commit comments