File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
docs/docs/reference/new-types Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,18 @@ The type `S & T` represents values that are of the type `S` and `T` at the same
11
11
12
12
``` scala
13
13
trait Resettable {
14
- def reset (): this . type
14
+ def reset (): Unit
15
15
}
16
16
trait Growable [T ] {
17
- def add (x : T ): this . type
17
+ def add (t : T ): Unit
18
18
}
19
19
def f (x : Resettable & Growable [String ]) = {
20
20
x.reset()
21
21
x.add(" first" )
22
22
}
23
23
```
24
24
25
- The value ` x ` is required to be _ both_ a ` Resettable ` and a
25
+ The parameter ` x ` is required to be _ both_ a ` Resettable ` and a
26
26
` Growable[String] ` .
27
27
28
28
The members of an intersection type ` A & B ` are all the members of ` A ` and all
@@ -51,8 +51,8 @@ can be further simplified to `List[A & B]` because `List` is
51
51
covariant.
52
52
53
53
One might wonder how the compiler could come up with a definition for
54
- ` children ` of type ` List[A & B] ` since all its is given are ` children `
55
- definitions of type ` List[A] ` and ` List[B] ` . The answer is it does not
54
+ ` children ` of type ` List[A & B] ` since what is given are ` children `
55
+ definitions of type ` List[A] ` and ` List[B] ` . The answer is the compiler does not
56
56
need to. ` A & B ` is just a type that represents a set of requirements for
57
57
values of the type. At the point where a value is _ constructed_ , one
58
58
must make sure that all inherited members are correctly defined.
You can’t perform that action at this time.
0 commit comments