Skip to content

zh-cn for Scala Tour: inner-classes.md #1194

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 4, 2018

Conversation

realwunan
Copy link
Contributor

Simplified Chinese version of Scala Tour: Inner Classes

@@ -13,3 +13,70 @@ language: zh-cn
next-page: abstract-types
previous-page: lower-type-bounds
---

在Scala中,一个类可以作为另一个类的成员。 在一些类似 Java 的语言中,内部类是外部类的成员,而 Scala 正好相反,内部类是绑定到外部对象的。 假设我们希望编译器在编译时阻止我们搞乱节点 nodes 与图形 graph 的关系。 路径依赖的类型提供了一种解决方案。
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.


在Scala中,一个类可以作为另一个类的成员。 在一些类似 Java 的语言中,内部类是外部类的成员,而 Scala 正好相反,内部类是绑定到外部对象的。 假设我们希望编译器在编译时阻止我们搞乱节点 nodes 与图形 graph 的关系。 路径依赖的类型提供了一种解决方案。

为了说明差异,我们简单描述了图形 graph 数据类型的实现:
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.

}
}
```
该程序将图形表示为节点列表 (`List[Node]`)。 每个节点都有一个用来存储与其相连的其他节点的列表 (`connectedNodes`)。 类 `class Node` 是一个 _路径依赖的类型_,因为它嵌套在类 `class Graph` 中。 因此,`connectedNodes` 中存储的所有节点必须使用同一个 `Graph` 的实例对象的 `newNode` 方法来创建。
Copy link
Contributor

Choose a reason for hiding this comment

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

class Node --> 类Node ?

路径依赖的类型 -> 路径依赖类型

class Graph -> 类 Graph

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.
class Graph 是根据英文原文来的,的确不妥。

@liufengyun
Copy link
Contributor

Thanks a lot, @realwunan 🎉

@liufengyun liufengyun merged commit 0d43def into scala:master Dec 4, 2018
@realwunan realwunan deleted the inner-classes branch December 4, 2018 12:44
bishabosha pushed a commit to bishabosha/docs.scala-lang that referenced this pull request Mar 21, 2022
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.

2 participants