Skip to content

Commit 732f3a2

Browse files
committed
Fix Simplify Chinese translation of Scala Tour: type-inference according to liufengyu's suggestion
1 parent 7c05384 commit 732f3a2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_zh-cn/tour/type-inference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ def id[T](x: T) = x
4646
val q = id(1) // type: Int
4747
```
4848

49-
编译器使用参数 `MyPair` 的类型来推断出 `A``B` 的类型。对于 `x` 的类型同样如此。
49+
编译器使用传给 `MyPair` 参数的类型来推断出 `A``B` 的类型。对于 `x` 的类型同样如此。
5050

5151
## 参数
5252

53-
编译器从不推断方法参数的类型。 但是,在某些情况下,当函数作为参数传递时,它可以推断出匿名函数参数类型
53+
编译器从不推断方法形式参数的类型。 但是,在某些情况下,当函数作为参数传递时,编译器可以推断出匿名函数形式参数的类型
5454

5555
```tut
5656
Seq(1, 3, 4).map(x => x * 2) // List(2, 6, 8)
5757
```
5858

59-
方法 map 的参数是 `f: A => B`。 因为我们把整数放在 `Seq` 中,编译器知道 `A``Int` 类型 (即 `x` 是一个整数)。 因此,编译器可以从 `x * 2` 推断出 `B``Int` 类型。
59+
方法 map 的形式参数是 `f: A => B`。 因为我们把整数放在 `Seq` 中,编译器知道 `A``Int` 类型 (即 `x` 是一个整数)。 因此,编译器可以从 `x * 2` 推断出 `B``Int` 类型。
6060

6161
## 何时 _不要_ 依赖类型推断
6262

63-
通常认为声明在公共 API 中的成员类型更具可读性。 因此,我们建议你为将在你的代码中向用户公开的任何 API 明确指定类型。
63+
通常认为,公开可访问的 API 成员应该具有显示类型声明。 因此,我们建议你为将在你的代码中向用户公开的任何 API 明确指定类型。
6464

6565
此外,类型推断有时会推断出太具体的类型。 假设我们这么写:
6666

6767
```tut
6868
var obj = null
6969
```
7070

71-
我们就不能继续重新分配值
71+
我们就不能进行重新赋值
7272

7373
```tut:fail
7474
obj = new AnyRef

0 commit comments

Comments
 (0)