Skip to content

Commit 4868d6e

Browse files
fResultsila-strike
authored andcommittedOct 27, 2024
update code block to fix markdown error which IntelliJ raised
1 parent e3c764d commit 4868d6e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed
 

‎_th/tour/traits.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ trait Iterator[A] {
4444

4545
{% tab 'Scala 3' for=trait-iterator-definition %}
4646

47-
```scala
47+
```scala 3
4848
trait Iterator[A]:
4949
def hasNext: Boolean
5050
def next(): A
@@ -92,7 +92,7 @@ iterator.next() // returns 1
9292

9393
{% tab 'Scala 3' for=trait-intiterator-definition %}
9494

95-
```scala
95+
```scala 3
9696
trait Iterator[A]:
9797
def hasNext: Boolean
9898
def next(): A
@@ -135,9 +135,7 @@ iterator.next() // returns 1
135135
> val dog = new Dog("Harry") // คลาส `Dog` เป็น subtype ของ trait `Pet`
136136
>
137137
> // parameter `pet` มี type เป็น trait `Pet`
138-
> def getPetName(pet: Pet): String {
139-
> return pet.name
140-
> }
138+
> def getPetName(pet: Pet): String = pet.name
141139
>
142140
> getPetName(dog)
143141
> ```
@@ -173,7 +171,7 @@ animals.foreach(pet => println(pet.name)) // แสดงค่า Harry Sally
173171
174172
{% tab 'Scala 3' for=trait-pet-example %}
175173
176-
```scala
174+
```scala 3
177175
import scala.collection.mutable.ArrayBuffer
178176
179177
trait Pet:

0 commit comments

Comments
 (0)