-
Notifications
You must be signed in to change notification settings - Fork 5.3k
第十四章 修正Optional类标题下的第一段 #595
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
Conversation
这段的译文确实不太好懂,所以我尝试着修改了一下。 不过,Happy Path 这个词没似乎没有正式的术语。 有道词典显示,有36个网页翻译成了「快乐路径」,有4个网页翻译成了「愉悦路径」,因此我采取了「快乐路径」这个译法。
空流应该还是更准确一点吧。。。囧
docs/book/14-Streams.md
Outdated
在我们学习终端操作(Terminal Operations)之前,我们必须考虑如果你在一个空流中获取元素会发生什么。我们喜欢为了“happy path”而将流连接起来,并假设流不会被中断。在流中放置 `null` 是很好的中断方法。那么是否有某种对象,可作为流元素的持有者,即使查看的元素不存在也能友好地提示我们(也就是说,不会发生异常)? | ||
在我们学习终端操作(Terminal Operations)之前,我们必须考虑在一个空流中获取元素会发生什么。我们喜欢沿着“快乐路径”[^1]把流连接起来,同时假设流不会中断。然而,在流中放置 `null` 却会轻易令其中断。那么是否存在某种对象,可以在持有流元素的同时,即使在我们查找的元素不存在时,也能友好地对我们进行提示(也就是说,不会产生异常)? | ||
|
||
[^1]: 在软件或信息建模的上下文中,快乐路径(有时称为快乐流)是没有异常或错误条件的默认场景。例如,验证信用卡号的函数的快乐路径应该是任何验证规则都不会出现错误的地方,从而让执行成功地继续到最后,生成一个积极的响应。[见 wikipedia: happy path](https://en.wikipedia.org/wiki/Happy_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.
脚注放到最后面一起。怎么放到这里了
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.
emmm 在本地用pandoc会自动把脚注放到后面。Gitbook 好像比较蛋疼一点。。。好吧,我改 qaq
@@ -1138,7 +1138,7 @@ is it | |||
<!-- Optional --> | |||
## Optional类 | |||
|
|||
在我们学习终端操作(Terminal Operations)之前,我们必须考虑如果你在一个空流中获取元素会发生什么。我们喜欢为了“happy path”而将流连接起来,并假设流不会被中断。在流中放置 `null` 是很好的中断方法。那么是否有某种对象,可作为流元素的持有者,即使查看的元素不存在也能友好地提示我们(也就是说,不会发生异常)? | |||
在我们学习终端操作(Terminal Operations)之前,我们必须考虑在一个空流中获取元素会发生什么。我们喜欢沿着“快乐路径”[^1]把流连接起来,同时假设流不会中断。然而,在流中放置 `null` 却会轻易令其中断。那么是否存在某种对象,可以在持有流元素的同时,即使在我们查找的元素不存在时,也能友好地对我们进行提示(也就是说,不会产生异常)? |
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.
这一段话的原文都放上来吧
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.
Before we can look at terminal operations, we must consider what
happens if you ask for an object in a stream and there's nothing
there. We like to connect up our streams for the "happy path" and
assume nothing will break. Putting a null in a stream is a good
way to break it. Is there some kind of object we can use that will
act as a holder for a stream element, but can also kindly tell us
(that is, no exceptions) if the element we're looking for isn't there?
This idea is implemented as the Optional type. Certain standard
stream operations return Optional objects because they cannot
guarantee the desired result will exist. These include:
这段的译文确实不太好懂,所以我尝试着修改了一下。
不过,Happy Path 这个词没似乎没有正式的术语。
有道词典显示,有36个网页翻译成了「快乐路径」,有4个网页翻译成了「愉悦路径」,因此我采取了「快乐路径」这个译法。