-
Notifications
You must be signed in to change notification settings - Fork 5.1k
1342: ReferenceManual / patterns.md + Expressions.md ⭐️⭐️⭐️⭐️ +⭐️⭐️⭐️⭐️⭐️ #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1342: ReferenceManual / patterns.md + Expressions.md ⭐️⭐️⭐️⭐️ +⭐️⭐️⭐️⭐️⭐️ #1390
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第一波 review
bind new named variables or constants to their matching values. For example, | ||
you can decompose the elements of a tuple and bind the value of each element to a | ||
corresponding identifier pattern. | ||
值绑定模式中的标识符模式将新的命名变量或常量绑定到其匹配值。例如,您可以分解元组的元素并将每个元素的值绑定到相应的标识符模式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原文中的主语是:Identifiers patterns
建议:标识符模式在值绑定模式中将新的命名变量或常量绑定到其匹配的值。
Enumeration case patterns appear in `switch` statement | ||
case labels and in the case conditions of `if`, `while`, `guard`, and `for`-`in` | ||
statements. | ||
*枚举大小写模式* 与现有枚举类型的大小写匹配。枚举 case 模式出现在 `switch` 语句 case 标签以及 `if` 、 `while` 、 `guard` 和`for` - `in` 语句的 case 条件中。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、上述有两处:【枚举大小写模式】==》【枚举案例模式】
2、建议:【枚举大小写模式 与现有枚举类型的大小写匹配】==〉【枚举案例模式匹配现有枚举类型的某个案例】
one element for each associated value. For an example that uses a `switch` statement | ||
to match enumeration cases containing associated values, | ||
see <doc:Enumerations#Associated-Values>. | ||
如果您尝试匹配的枚举大小写具有任何关联值,则相应的枚举大小写模式必须指定一种元组模式,其中每个关联值都包含一个元素。有关使用`switch` 语句来匹配包含关联值的枚举情况的示例,请参阅 <doc:Enumerations#Associated-Values>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、上述有一处:【枚举大小写】 ==》【枚举案例】
2、建议:【有关使用switch
语句来匹配包含关联值的枚举情况的示例】==〉【以下是一个使用 switch 语句匹配包含关联值的枚举案例的示例】
because `Optional` is implemented as an enumeration, | ||
`.none` and `.some` can appear | ||
in the same switch as the cases of the enumeration type. | ||
枚举大小写模式还匹配包装在可选值中的该大小写的值。这种简化的语法允许您省略可选模式。请注意,由于 `Optional` 是作为枚举实现的,因此 `.none` 和 `.some` 可以与枚举类型的情况出现在同一开关中 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、上述有两处:【枚举大小写】==》【枚举案例】
2、【枚举大小写模式还匹配包装在可选值中的该大小写的值】==〉【枚举案例模式还可以匹配包装在可选中的该案例值】
3、switch 不应翻译为开关:【.none
和 .some
可以与枚举类型的情况出现在同一开关中】==》【.none 和 .some 可以与枚举类型的案例在同一个 switch 语句中出现】
of an `Optional<Wrapped>` enumeration. | ||
Optional patterns consist of an identifier pattern followed immediately by a question mark | ||
and appear in the same places as enumeration case patterns. | ||
可选模式与包含在 `Optional<Wrapped>` 枚举的 `some(Wrapped)` 情况中的值相匹配。可选模式由标识符模式组成,后面紧跟一个问号,并出现在与枚举案例模式相同的位置 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
【可选模式由标识符模式组成,后面紧跟一个问号】==》【可选模式由标识符模式紧跟问号组成】
the type specified in the right-hand side of the `is` pattern --- or a subclass of that type. | ||
The `is` pattern behaves like the `is` operator in that they both perform a type cast | ||
but discard the returned type. | ||
如果运行时值的 `is` 与 `is` 模式与该值匹配 - 或者该类型的子类。 `is` 模式的行为类似于 `is` 运算符,因为它们都执行类型转换但丢弃返回的类型。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、【如果运行时值的 is
与 is
模式与该值匹配 - 或者该类型的子类】此句不通顺,
建议 ==》【is 模式在运行时匹配一个值,如果该值的类型与 is 模式右侧指定的类型相同——或者是该类型的子类。】
2、建议加个标点符号:【因为它们都执行类型转换但丢弃返回的类型】==》【它们都执行类型转换,但会丢弃返回的类型】
If the match succeeds, | ||
the type of the matched value is cast to the *pattern* specified in the right-hand side | ||
of the `as` pattern. | ||
如果运行时该值的类型与`as模` 式右侧指定的类型相同,则 `as` 模式与该值匹配 - 或者该类型的子类。如果匹配成功,则匹配值的类型将转换为 `as` 模式右侧指定的模式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1、【如果运行时该值的类型与as模
式右侧指定的类型相同,则 as
模式与该值匹配 - 或者该类型的子类】==》【as 模式在运行时匹配一个值,如果该值的类型与 as 模式右侧指定的类型相同——或者是该类型的子类】
@king-open 可以采纳合理的 Review Comment Thx! |
in the sections below. | ||
|
||
> Grammar of an expression: | ||
# 表达 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
表达式
@Ryan-BetterMe 可以看看改完的有没有问题 THX! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
标题需要修改
> | ||
> *identifier-pattern* → *identifier* | ||
|
||
## Value-Binding Pattern | ||
## 价值绑定模式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
价值绑定模式 ==》值绑定模式
@@ -300,16 +231,11 @@ case nil: | |||
> | |||
> *enum-case-pattern* → *type-identifier*_?_ **`.`** *enum-case-name* *tuple-pattern*_?_ | |||
|
|||
## Optional Pattern | |||
## 可选图案 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可选图案 ==》 可选模式
|
||
> Grammar of a type casting pattern: | ||
> | ||
> *type-casting-pattern* → *is-pattern* | *as-pattern* \ | ||
> *is-pattern* → **`is`** *type* \ | ||
> *as-pattern* → *pattern* **`as`** *type* | ||
|
||
## Expression Pattern | ||
## 表达模式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
表达模式 ==》表达式模式
@Ryan-BetterMe 可以再 Review 一下 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review Expressions.md 中有部分文件需要修改
|
||
### In-Out Expression | ||
### 输入输出表达式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-Out 不用翻译
An *in-out expression* marks a variable | ||
that's being passed | ||
as an in-out argument to a function call expression. | ||
输入输出表达式 将函数调用表达式传入的变量标记为输入输出实参。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输入输出表达式 ==> in-out 表达式
|
||
> Grammar of an in-out expression: | ||
> 输入输出表达式语法: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输入输出表达式语法 ==》 in-out 表达式语法。
PS:in-out 相关的全文检查一下,这个不用翻译。
> | ||
> *in-out-expression* → **`&`** *primary-expression* | ||
> *输入输出表达式* → **`&`** *标识符* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输入输出表达式 ==》 in-out 表达式
> | ||
> *macro-expansion-expression* → **`#`** *identifier* *generic-argument-clause*_?_ *function-call-argument-clause*_?_ *trailing-closures*_?_ | ||
|
||
### Key-Path Expression | ||
### 键路径表达式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:键路径表达式 ==> Key-Path 表达式
@@ -2138,21 +986,15 @@ see [Using Objective-C Runtime Features in Swift](https://developer.apple.com/do | |||
optional binding. | |||
--> | |||
|
|||
### Key-Path String Expression | |||
### 键路径字符串表达式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:键路径字符串表达式 ==> Key-Path 字符串表达式
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
个别小问题,基本 OK 了
@@ -337,193 +153,81 @@ see [Operator Declarations](https://developer.apple.com/documentation/swift/oper | |||
> *infix-expression* → *type-casting-operator* \ | |||
> *infix-expressions* → *infix-expression* *infix-expressions*_?_ | |||
|
|||
### Assignment Operator | |||
### 赋值表达式 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赋值表达式 ==> 赋值运算符
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.