@@ -2424,22 +2424,13 @@ extension Array: Serializable where Element: SerializableInArray {
2424
2424
```
2425
2425
-->
2426
2426
2427
- #### Resolving Implicit Redundancy
2427
+ #### 解决隐式冗余
2428
2428
2429
- When a concrete type conditionally conforms to a protocol,
2430
- that type implicitly conforms to any parent protocols
2431
- with the same requirements.
2429
+ 当一个具体类型有条件地遵循一个协议时,该类型隐式地遵循任何具有相同要求的父协议。
2432
2430
2433
- If you need a type to conditionally conform to two protocols
2434
- that inherit from a single parent,
2435
- explicitly declare conformance to the parent protocol.
2436
- This avoids implicitly conforming to the parent protocol twice
2437
- with different requirements.
2431
+ 如果您需要一个类型有条件地遵循两个继承自单一父协议的协议,请明确声明对父协议的遵循。这可以避免以不同的要求隐式地两次遵循父协议。
2438
2432
2439
- The following example explicitly declares
2440
- the conditional conformance of ` Array ` to ` Loggable `
2441
- to avoid a conflict when declaring its conditional conformance
2442
- to both ` TitledLoggable ` and the new ` MarkedLoggable ` protocol.
2433
+ 以下示例明确声明了` Array ` 对` Loggable ` 的条件遵循,以避免在声明其对` TitledLoggable ` 和新的` MarkedLoggable ` 协议的条件遵循时发生冲突。
2443
2434
2444
2435
``` swift
2445
2436
protocol MarkedLoggable : Loggable {
@@ -2487,10 +2478,7 @@ extension Array: MarkedLoggable where Element: MarkedLoggable { }
2487
2478
```
2488
2479
-->
2489
2480
2490
- Without the extension
2491
- to explicitly declare conditional conformance to ` Loggable ` ,
2492
- the other ` Array ` extensions would implicitly create these declarations,
2493
- resulting in an error:
2481
+ 在没有扩展明确声明对 ` Loggable ` 的条件遵循时,其他 ` Array ` 扩展会隐式创建这些声明,从而导致错误:
2494
2482
2495
2483
``` swift
2496
2484
extension Array : Loggable where Element : TitledLoggable { }
@@ -2579,21 +2567,13 @@ extension Array: Loggable where Element: MarkedLoggable { }
2579
2567
```
2580
2568
-->
2581
2569
2582
- > Grammar of an extension declaration:
2570
+ > 扩展声明的语法:
2583
2571
>
2584
- > * extension-declaration * → * attributes * _ ?_ * access-level-modifier * _ ?_ ** ` extension ` ** * type-identifier * * type-inheritance-clause * _ ?_ * generic-where-clause * _ ?_ * extension-body * \
2585
- > * extension-body * → ** ` { ` ** * extension-members * _ ?_ ** ` } ` **
2572
+ > * 扩展声明 * → * 属性 * _ ?_ * 访问级别修饰符 * _ ?_ ** ` 扩展 ` ** * 类型标识符 * * 类型继承条款 * _ ?_ * 泛型约束条款 * _ ?_ * 扩展主体 * \
2573
+ > * 扩展主体 * → ** ` { ` ** * 扩展成员 * _ ?_ ** ` } ` **
2586
2574
>
2587
- > * extension-members* → * extension-member* * extension-members* _ ?_ \
2588
- > * extension-member* → * declaration* | * compiler-control-statement*
2589
-
2590
- ## Subscript Declaration
2591
-
2592
- A * subscript* declaration allows you to add subscripting support for objects
2593
- of a particular type and are typically used to provide a convenient syntax
2594
- for accessing the elements in a collection, list, or sequence.
2595
- Subscript declarations are declared using the ` subscript ` keyword
2596
- and have the following form:
2575
+ > * 扩展成员* → * 扩展成员* * 扩展成员* _ ?_ \
2576
+ > * 扩展成员* → * 声明* | * 编译器控制语句*
2597
2577
2598
2578
``` swift
2599
2579
subscript (<#parameters#>) -> <#return type#> {
0 commit comments