Skip to content

zh-cn for Scala Tour:singleton-objects.md #1179

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 3 commits into from
Dec 3, 2018

Conversation

realwunan
Copy link
Contributor

Simplified Chinese version of Scala Tour: Singleton Objects

@SethTisue
Copy link
Member

needs a reviewer...

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

@@ -13,3 +13,100 @@ language: zh-cn
next-page: regular-expression-patterns
previous-page: pattern-matching
---

单例对象是一种特殊的类,有且只有一个实例。和惰性变量一样,单例对象是延迟创建的,当它被引用到的时候创建。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当它被引用到的时候创建

英语原文不是很精准,我觉得汉语可以改进为当它第一次被使用时创建

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单例对象是一种特殊的类,有且只有一个实例。

英文原文非常不精准,如class A { object B },可能有很多B的实例。在tour里面,也许简单比较好,不用过于精确而导致理解困难。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.


单例对象是一种特殊的类,有且只有一个实例。和惰性变量一样,单例对象是延迟创建的,当它被引用到的时候创建。

作为一个顶级值,单例对象只有一个实例。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当对象定义于顶层时(即没有包含在其他类中)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.


作为一个顶级值,单例对象只有一个实例。

作为一种包装类,或者局部值,单例对象表现得和惰性变量一样。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当对象定义在一个类或方法中时

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段我原来是直译的英文,非常不好。谢谢刘大的翻译


因为 import 语句 `import logging.Logger.info`,方法 `info` 在此处是可见的。

import语句要求被导入的标识具有一个“静态位置”,一个单例对象由于全局唯一,所以具有静态位置。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

静态位置 -> 稳定路径

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution 🎉

@liufengyun liufengyun merged commit f598511 into scala:master Dec 3, 2018
@realwunan realwunan deleted the singleton-objects branch December 3, 2018 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants