Skip to content

Commit 986ec91

Browse files
authored
Update abstract-types.md
1 parent 01cb8e0 commit 986ec91

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

_zh-cn/tour/abstract-types.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ abstract class SeqBuffer extends Buffer {
2929
def length = element.length
3030
}
3131
```
32-
需要注意的是我们之前没有使用过抽象类型`type U`做类型边界上限。
33-
这个`Class SeqBuffer`只允许我们在Buffer中存入序列类型是`Seq[U]`子类的`T`,并且U是一个新的抽象类型。
32+
注意这里是如何借助另外一个抽象类型U来限定类型边界上限(upper-type-bound)。通过声明类型T只可以是Seq[U]的子类(其中U是一个新的抽象类型),这个SeqBuffer类就限定了缓冲区中存储的元素类型只能是序列。
3433

3534
特征和抽象类经常和匿名类一起使用。示例如下,我们现在看一个程序,它处理一个引用整数列表的序列Buffer:
3635

0 commit comments

Comments
 (0)