Skip to content

Commit d529b9d

Browse files
gkepkasila-strike
authored andcommitted
Fix double declaration of classes and functions
1 parent f6cce08 commit d529b9d

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

_tour/pattern-matching.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,31 +242,15 @@ You can use variable binding to get type-dependent behavior while simultaneously
242242
{% tabs pattern-matching-variable-binding class=tabs-scala-version %}
243243
{% tab 'Scala 2' for=pattern-matching-variable-binding %}
244244
```scala mdoc
245-
sealed trait Device
246-
case class Phone(model: String) extends Device {
247-
def screenOff = "Turning screen off"
248-
}
249-
case class Computer(model: String) extends Device {
250-
def screenSaverOn = "Turning screen saver on..."
251-
}
252-
253-
def goIdle(device: Device): String = device match {
245+
def goIdleWithModel(device: Device): String = device match {
254246
case p @ Phone(model) => s"$model: ${p.screenOff}"
255247
case c @ Computer(model) => s"$model: ${c.screenSaverOn}"
256248
}
257249
```
258250
{% endtab %}
259251
{% tab 'Scala 3' for=pattern-matching-variable-binding %}
260252
```scala
261-
sealed trait Device
262-
case class Phone(model: String) extends Device:
263-
def screenOff = "Turning screen off"
264-
265-
case class Computer(model: String) extends Device:
266-
def screenSaverOn = "Turning screen saver on..."
267-
268-
269-
def goIdle(device: Device): String = device match
253+
def goIdleWithModel(device: Device): String = device match
270254
case p @ Phone(model) => s"$model: ${p.screenOff}"
271255
case c @ Computer(model) => s"$model: ${c.screenSaverOn}"
272256
```

0 commit comments

Comments
 (0)