You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The question arises what the type of the parameter `obj` is. If it's `Cloneable` then the object can be `clone`d, but not `reset`; if it's `Resetable` we can `reset` it, but there is no `clone` operation. To avoid type casts in such a situation, we can specify the type of `obj` to be both `Cloneable` and `Resetable`. This compound type is written like this in Scala: `Cloneable with Resetable`.
63
+
The question arises what the type of the parameter `obj` is. If it's `Cloneable` then the object can be `clone`d, but not `reset`; if it's `Resetable` we can `reset` it, but there is no `clone` operation. To avoid type casts in such a situation, we can specify the type of `obj` to be both `Cloneable` and `Resetable`.
Compound types can consist of several object types and they may have a single refinement which can be used to narrow the signature of existing object members.
49
75
The general form is: `A with B with C ... { refinement }`
76
+
{% endtab %}
77
+
{% tab 'Scala 3' for=compound-types_2 %}
78
+
This compound type is written like this in Scala: `Cloneable & Resetable`.
Compound types can consist of several object types and they may have a single refinement which can be used to narrow the signature of existing object members.
87
+
The general form is: `A & B & C ... { refinement }`
88
+
{% endtab %}
89
+
{% endtabs %}
50
90
51
91
An example for the use of refinements is given on the page about [class composition with mixins](mixin-class-composition.html).
0 commit comments