Skip to content

Commit cb412b2

Browse files
authored
Update Extractor.scala
1 parent 9924aab commit cb412b2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/scala/com/thoughtworks/Extractor.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ package com.thoughtworks
66
* @example
77
{{{
88
import com.thoughtworks.Extractor._
9-
10-
// Convert a PartialFunction to a pattern
9+
10+
// Define a PartialFunction
1111
val pf: PartialFunction[Int, String] = {
1212
case 1 => "matched by PartialFunction"
1313
}
14-
15-
// Convert an optional function to a pattern
14+
15+
// Define an optional function
1616
val f: Int => Option[String] = { i =>
1717
if (i == 2) {
1818
Some("matched by optional function")
1919
} else {
2020
None
2121
}
2222
}
23-
23+
2424
// Convert an optional function to a PartialFunction
2525
val pf2: PartialFunction[Int, String] = f.unlift
26-
26+
2727
util.Random.nextInt(4) match {
28-
case pf.extract(m) =>
28+
case pf.extract(m) => // Convert a PartialFunction to a pattern
2929
println(m)
30-
case f.extract(m) =>
30+
case f.extract(m) => // Convert an optional function to a pattern
3131
println(m)
32-
case pf2.extract(m) =>
32+
case pf2.extract(m) => // Convert a PartialFunction to a pattern
3333
throw new AssertionError("This case should never occur because it has the same condition as `f.extract`.")
3434
case _ =>
3535
println("Not matched")

0 commit comments

Comments
 (0)