Skip to content

Commit 307fb5d

Browse files
authored
Merge pull request #1287 from fabiopakk/patch-3
More precise wording in abstract-type-members.md
2 parents 19e2d77 + d2e2627 commit 307fb5d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

_tour/abstract-type-members.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class SeqBuffer extends Buffer {
3434
def length = element.length
3535
}
3636
```
37-
Notice how we can use yet another abstract `type U` as an upper-type-bound. This `class SeqBuffer` allows us to store only sequences in the buffer by stating that type `T` has to be a subtype of `Seq[U]` for a new abstract type `U`.
37+
Notice how we can use yet another abstract type `U` in the specification of an upper-type-bound for `T`. This `class SeqBuffer` allows us to store only sequences in the buffer by stating that type `T` has to be a subtype of `Seq[U]` for a new abstract type `U`.
3838

3939
Traits or [classes](classes.html) with abstract type members are often used in combination with anonymous class instantiations. To illustrate this, we now look at a program which deals with a sequence buffer that refers to a list of integers:
4040

@@ -53,7 +53,7 @@ val buf = newIntSeqBuf(7, 8)
5353
println("length = " + buf.length)
5454
println("content = " + buf.element)
5555
```
56-
Here the factory `newIntSeqBuf` uses an anonymous class implementation of `IntSeqBuf` (i.e. `new IntSeqBuffer`), setting `type T` to a `List[Int]`.
56+
Here the factory `newIntSeqBuf` uses an anonymous class implementation of `IntSeqBuf` (i.e. `new IntSeqBuffer`) to set the abstract type `T` to the concrete type `List[Int]`.
5757

5858
It is also possible to turn abstract type members into type parameters of classes and vice versa. Here is a version of the code above which only uses type parameters:
5959

@@ -75,4 +75,4 @@ println("length = " + buf.length)
7575
println("content = " + buf.element)
7676
```
7777

78-
Note that we have to use [variance annotations](variances.html) here (`+T <: Seq[U]`) in order to hide the concrete sequence implementation type of the object returned from method `newIntSeqBuf`. Furthermore, there are cases where it is not possible to replace abstract types with type parameters.
78+
Note that we have to use [variance annotations](variances.html) here (`+T <: Seq[U]`) in order to hide the concrete sequence implementation type of the object returned from method `newIntSeqBuf`. Furthermore, there are cases where it is not possible to replace abstract type members with type parameters.

0 commit comments

Comments
 (0)