-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
needs a reviewer... |
…ding to declan94's suggestions
8b42c7b
to
0d521d1
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.
Otherwise, LGTM
_zh-cn/tour/singleton-objects.md
Outdated
@@ -13,3 +13,100 @@ language: zh-cn | |||
next-page: regular-expression-patterns | |||
previous-page: pattern-matching | |||
--- | |||
|
|||
单例对象是一种特殊的类,有且只有一个实例。和惰性变量一样,单例对象是延迟创建的,当它被引用到的时候创建。 |
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.
单例对象是一种特殊的类,有且只有一个实例。
英文原文非常不精准,如class A { object B }
,可能有很多B的实例。在tour里面,也许简单比较好,不用过于精确而导致理解困难。
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/singleton-objects.md
Outdated
|
||
单例对象是一种特殊的类,有且只有一个实例。和惰性变量一样,单例对象是延迟创建的,当它被引用到的时候创建。 | ||
|
||
作为一个顶级值,单例对象只有一个实例。 |
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/singleton-objects.md
Outdated
|
||
作为一个顶级值,单例对象只有一个实例。 | ||
|
||
作为一种包装类,或者局部值,单例对象表现得和惰性变量一样。 |
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.
这段我原来是直译的英文,非常不好。谢谢刘大的翻译
_zh-cn/tour/singleton-objects.md
Outdated
|
||
因为 import 语句 `import logging.Logger.info`,方法 `info` 在此处是可见的。 | ||
|
||
import语句要求被导入的标识具有一个“静态位置”,一个单例对象由于全局唯一,所以具有静态位置。 |
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.
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.
LGTM, thanks for your contribution 🎉
Simplified Chinese version of Scala Tour: Singleton Objects