Skip to content

Repaired a logical error in chinese tour of scala. #1603

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 1 commit into from
Dec 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _zh-cn/tour/variances.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ abstract class SmallAnimal extends Animal
case class Mouse(name: String) extends SmallAnimal
```

假设我们正在处理接受动物类型的函数,并返回他们的食物类型。 如果我们想要一个 `Cat => SmallAnimal`(因为猫吃小动物),但是给它一个 `Animal => Mouse`,我们的程序仍然可以工作。 直观地看,一个 `Animal => Mouse` 的函数仍然会接受一个 `Cat` 作为参数,因为 `Cat` 即是一个 `Animal`,并且这个函数返回一个 `Mouse`,也是一个 `SmallAnimal`。 既然我们可以安全地,隐式地用前者代替后者,我们可以说 `Animal => Mouse` 是 `Cat => SmallAnimal` 的子类型。
假设我们正在处理接受动物类型的函数,并返回他们的食物类型。 如果我们想要一个 `Cat => SmallAnimal`(因为猫吃小动物),但是给它一个 `Animal => Mouse`,我们的程序仍然可以工作。 直观地看,一个 `Animal => Mouse` 的函数仍然会接受一个 `Cat` 作为参数,因为 `Cat` 即是一个 `Animal`,并且这个函数返回一个 `Mouse`,也是一个 `SmallAnimal`。 既然我们可以安全地,隐式地用后者代替前者,我们可以说 `Animal => Mouse` 是 `Cat => SmallAnimal` 的子类型。

### 与其他语言的比较

Expand Down