Skip to content

Commit 6b3d1f2

Browse files
authored
Adopt feedback from adpi2
1 parent e4bbc9b commit 6b3d1f2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

_tour/pattern-matching.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,28 @@ We can also use extractor objects for string pattern matching.
173173
{% tabs s-interpolator-pattern-matching-2 class=tabs-scala-version %}
174174
{% tab 'Scala 2' for=s-interpolator-pattern-matching-2 %}
175175
```scala
176-
object Int {
176+
object Age {
177177
def unapply(s: String): Option[Int] = s.toIntOption
178178
}
179179

180180
val input: String = "Alice is 25 years old"
181181

182182
val (name, age) = input match {
183-
case s"$name is ${Int(age)} years old" => (name, age)
183+
case s"$name is ${Age(age)} years old" => (name, age)
184184
}
185185
// name: String = Alice
186186
// age: Int = 25
187187
```
188188
{% endtab %}
189189
{% tab 'Scala 3' for=s-interpolator-pattern-matching-2 %}
190190
```scala
191-
object Int:
191+
object Age:
192192
def unapply(s: String): Option[Int] = s.toIntOption
193193

194194
val input: String = "Alice is 25 years old"
195195

196196
val (name, age) = input match
197-
case s"$name is ${Int(age)} years old" => (name, age)
197+
case s"$name is ${Age(age)} years old" => (name, age)
198198
// name: String = Alice
199199
// age: Int = 25
200200
```

0 commit comments

Comments
 (0)