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
Copy file name to clipboardExpand all lines: _overviews/scala3-book/domain-modeling-oop.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -151,7 +151,7 @@ trait TranslationService:
151
151
152
152
To compose the two services, we can simply create a new trait extending them:
153
153
154
-
{% tabs traits_5 class=tabs-scala-version %}
154
+
{% tabs traits_5 %}
155
155
{% tab 'Scala 2 and 3' for=traits_5 %}
156
156
157
157
```scala
@@ -210,7 +210,7 @@ class MyService(name: String) extends ComposedService, Showable:
210
210
211
211
We can create an instance of `MyService` as follows:
212
212
213
-
{% tabs class_2 class=tabs-scala-version %}
213
+
{% tabs class_2 %}
214
214
{% tab 'Scala 2 and 3' for=class_2 %}
215
215
216
216
```scala
@@ -222,7 +222,7 @@ val s1: MyService = MyService("Service 1")
222
222
223
223
Through the means of subtyping, our instance `s1` can be used everywhere that any of the extended traits is expected:
224
224
225
-
{% tabs class_3 class=tabs-scala-version %}
225
+
{% tabs class_3 %}
226
226
{% tab 'Scala 2 and 3' for=class_3 %}
227
227
228
228
```scala
@@ -238,7 +238,7 @@ val s4: Showable = s1
238
238
239
239
As mentioned before, it is possible to extend another class:
240
240
241
-
{% tabs class_4 class=tabs-scala-version %}
241
+
{% tabs class_4 %}
242
242
{% tab 'Scala 2 and 3' for=class_4 %}
243
243
244
244
```scala
@@ -254,7 +254,7 @@ However, since _traits_ are designed as the primary means of decomposition,
254
254
a class that is defined in one file _cannot_ be extended in another file.
255
255
In order to allow this, the base class needs to be marked as `open`:
256
256
257
-
{% tabs class_5 class=tabs-scala-version %}
257
+
{% tabs class_5 %}
258
258
{% tab 'Scala 2 and 3' for=class_5 %}
259
259
260
260
```scala
@@ -307,7 +307,7 @@ class Counter:
307
307
308
308
Every instance of the class `Counter` has its own private state that can only be observed through the method `count`, as the following interaction illustrates:
0 commit comments