Skip to content

Commit f1532f2

Browse files
authored
Add code tabs for _overviews/scala3-book/types-types-intersection.md
1 parent 3789cf6 commit f1532f2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

_overviews/scala3-book/types-intersection.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Used on types, the `&` operator creates a so called _intersection type_.
1313
The type `A & B` represents values that are **both** of the type `A` and of the type `B` at the same time.
1414
For instance, the following example uses the intersection type `Resettable & Growable[String]`:
1515

16+
{% tabs reset-grow class=tabs-scala-version %}
17+
{% tab 'Scala 3' %}
18+
1619
```scala
1720
trait Resettable:
1821
def reset(): Unit
@@ -24,6 +27,8 @@ def f(x: Resettable & Growable[String]): Unit =
2427
x.reset()
2528
x.add("first")
2629
```
30+
{% endtab %}
31+
{% endtabs %}
2732

2833
In the method `f` in this example, the parameter `x` is required to be *both* a `Resettable` and a `Growable[String]`.
2934

0 commit comments

Comments
 (0)