-
Notifications
You must be signed in to change notification settings - Fork 5.3k
修改13章函数式编程中不符合中文表达习惯的表述 #507
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,21 +104,21 @@ Hello there Hello there | |
|
||
**Strategy** 接口提供了单一的 `approach()` 方法来承载函数式功能。通过创建不同的 **Strategy** 对象,我们可以创建不同的行为。 | ||
|
||
传统上,我们通过创建一个实现 **Strategy** 接口的类来实现此行为,比如在 **Soft**。 | ||
我们一般通过创建一个实现**Strategy**接口的类来实现这种行为,正如在**Soft**里所做的。 | ||
|
||
- **[1]** 在 **Strategize** 中,**Soft** 作为默认策略,在构造函数中赋值。 | ||
- **[1]** 在 **Strategize** 中,你可以看到 **Soft** 作为默认策略,在构造函数中赋值。 | ||
|
||
- **[2]** 一种略显简短且更自发的方法是创建一个**匿名内部类**。即使这样,仍有相当数量的冗余代码。你总是要仔细观察:“哦,原来这样,这里使用了匿名内部类。” | ||
- **[2]** 一种较为简洁且更加自然的方法是创建一个**匿名内部类**。即便如此,仍有相当数量的冗余代码。你总需要仔细观察后才会发现:“哦,我明白了,原来这里使用了匿名内部类。” | ||
|
||
- **[3]** Java 8 的 Lambda 表达式。由箭头 `->` 分隔开参数和函数体,箭头左边是参数,箭头右侧是从 Lambda 返回的表达式,即函数体。这实现了与定义类、匿名内部类相同的效果,但代码少得多。 | ||
- **[3]** Java 8 的 Lambda 表达式,其参数和函数体被箭头 `->` 分隔开。箭头右侧是从 Lambda 返回的表达式。它与单独定义类和采用匿名内部类是等价的,但代码少得多。 | ||
|
||
- **[4]** Java 8 的**方法引用**,由 `::` 区分。在 `::` 的左边是类或对象的名称,在 `::` 的右边是方法的名称,但没有参数列表。 | ||
- **[4]** Java 8 的**方法引用**,它以 `::` 为特征。 `::` 的左边是类或对象的名称, `::` 的右边是方法的名称,但是没有参数列表。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 原文:This is the Jave 8 method reference, distinguished by the ::. |
||
|
||
- **[5]** 在使用默认的 **Soft** **strategy** 之后,我们逐步遍历数组中的所有 **Strategy**,并使用 `changeStrategy()` 方法将每个 **Strategy** 放入 变量 `s` 中。 | ||
- **[5]** 在使用默认的 **Soft** 策略之后,我们逐步遍历数组中的所有 **Strategy**,并通过调用 `changeStrategy()` 方法将每个 **Strategy** 传入变量 `s` 中。 | ||
|
||
- **[6]** 现在,每次调用 `communicate()` 都会产生不同的行为,具体取决于此刻正在使用的策略**代码对象**。我们传递的是行为,而非仅数据。[^3] | ||
- **[6]** 现在,每次调用 `communicate()` 都会产生不同的行为,具体取决于此刻正在使用的策略**代码对象**。我们传递的是行为,而并不仅仅是数据。[^3] | ||
|
||
在 Java 8 之前,我们能够通过 **[1]** 和 **[2]** 的方式传递功能。然而,这种语法的读写非常笨拙,并且我们别无选择。方法引用和 Lambda 表达式的出现让我们可以在需要时**传递功能**,而不是仅在必要才这么做。 | ||
在 Java 8 之前,我们能够通过 **[1]** 和 **[2]** 的方式传递功能。然而,这种语法的读写非常笨拙,并且我们别无选择。方法引用和 Lambda 表达式的出现让我们可以在需要时**传递功能**,而不是仅在必要时才这么做。 | ||
|
||
<!-- Lambda Expressions --> | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.