-
Notifications
You must be signed in to change notification settings - Fork 1k
zh-cn for Scala Tour:extractor-objects.md #1183
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
5b66b71
to
e755be5
Compare
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.
BTW, it seems the periods are not translated :)
_zh-cn/tour/extractor-objects.md
Outdated
|
||
这里 `apply` 方法用 `name` 创建一个 `CustomerID` 字符串. 而 `unapply` 方法正好相反, 它返回 `name` . 当我们调用 `CustomerID("Sukyoung")` , 其实是调用了 `CustomerID.apply("Sukyoung")` 的简化语法. 当我们调用 `case CustomerID(name) => println(name)`, 就是在调用提取器方法. | ||
|
||
因为在定义一个值的时候可以使用一个模式来引入一个新的变量, 提取器可以用来初始化这个变量, 使用 unapply 方法来生成值. |
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.
It's much better, thanks a lot.
_zh-cn/tour/extractor-objects.md
Outdated
|
||
* 如果只是用来测试, 返回一个 `Boolean` 类型的值. 例如 `case even()`. | ||
* 如果只是用来提取单个 T 类型的值, 返回 `Option[T]`. | ||
* 如果你想要提取多个值, 类型分别为 `T1,...,Tn`, 把它们放在一个可选的元祖中 `Option[(T1,...,Tn)]`. |
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.
typo: 元祖
-> 元组
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.
Thanks for pointing it out.
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.
Thanks a lot.
_zh-cn/tour/extractor-objects.md
Outdated
|
||
`unapply` 方法的返回值应当符合下面的某一条: | ||
|
||
* 如果只是用来测试, 返回一个 `Boolean` 类型的值. 例如 `case even()`. |
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.
语义通顺了很多
Just change the translation to use Chinese punctuation. |
LGTM, thanks a lot for the contribution @realwunan 🎉 |
Simplified Chinese version of Scala Tour: Extractor Objects