Skip to content

Commit 134df43

Browse files
committed
correct scala2 code. change to Scala 3 "Only".
1 parent 9edff29 commit 134df43

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

_overviews/scala3-book/domain-modeling-tools.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,18 @@ The class has three constructors, given by the numbered comments in the code:
325325

326326
Those constructors can be called like this:
327327

328-
{% tabs structor_2 %}
329-
{% tab 'Scala 2 and 3' for=structor_2 %}
328+
{% tabs structor_2 class=tabs-scala-version %}
329+
{% tab 'Scala 2' for=structor_2 %}
330+
331+
```scala
332+
val s1 = new Student("Mary", "123")
333+
val s2 = new Student("Mary", "123", LocalDate.now)
334+
val s3 = new Student("Mary", "123", 456)
335+
```
336+
337+
{% endtab %}
338+
339+
{% tab 'Scala 3' for=structor_2 %}
330340

331341
```scala
332342
val s1 = Student("Mary", "123")
@@ -836,7 +846,7 @@ Basic enumerations are used to define sets of constants, like the months in a ye
836846
As an example, these enumerations define sets of attributes related to pizzas:
837847

838848
{% tabs enum_1 %}
839-
{% tab 'Scala 3 only' for=enum_1 %}
849+
{% tab 'Scala 3 Only' for=enum_1 %}
840850

841851
```scala
842852
enum CrustSize:
@@ -855,7 +865,7 @@ enum Topping:
855865
To use them in other code, first import them, and then use them:
856866

857867
{% tabs enum_2 %}
858-
{% tab 'Scala 3 only' for=enum_2 %}
868+
{% tab 'Scala 3 Only' for=enum_2 %}
859869

860870
```scala
861871
import CrustSize.*
@@ -868,7 +878,7 @@ val currentCrustSize = Small
868878
Enum values can be compared using equals (`==`), and also enum_1ed on:
869879

870880
{% tabs enum_3 %}
871-
{% tab 'Scala 3 only' for=enum_3 %}
881+
{% tab 'Scala 3 Only' for=enum_3 %}
872882

873883
```scala
874884
// if/then
@@ -890,7 +900,7 @@ currentCrustSize enum_1
890900
Enumerations can also be parameterized:
891901

892902
{% tabs enum_4 %}
893-
{% tab 'Scala 3 only' for=enum_4 %}
903+
{% tab 'Scala 3 Only' for=enum_4 %}
894904

895905
```scala
896906
enum Color(val rgb: Int):
@@ -905,7 +915,7 @@ enum Color(val rgb: Int):
905915
And they can also have members (like fields and methods):
906916

907917
{% tabs enum_5 %}
908-
{% tab 'Scala 3 only' for=enum_5 %}
918+
{% tab 'Scala 3 Only' for=enum_5 %}
909919

910920
```scala
911921
enum Planet(mass: Double, radius: Double):
@@ -927,7 +937,7 @@ enum Planet(mass: Double, radius: Double):
927937
If you want to use Scala-defined enums as Java enums, you can do so by extending the class `java.lang.Enum` (which is imported by default) as follows:
928938

929939
{% tabs enum_6 %}
930-
{% tab 'Scala 3 only' for=enum_6 %}
940+
{% tab 'Scala 3 Only' for=enum_6 %}
931941

932942
```scala
933943
enum Color extends Enum[Color] { case Red, Green, Blue }

0 commit comments

Comments
 (0)