Skip to content

Commit 9924aab

Browse files
authored
Update README.md
1 parent a981b72 commit 9924aab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ libraryDependencies += "com.thoughtworks" %% "extractor" % "1.0.0"
1212

1313
``` scala
1414
import com.thoughtworks.Extractor._
15+
import com.thoughtworks.Extractor._
1516

16-
// Convert a PartialFunction to a pattern
17+
// Define a PartialFunction
1718
val pf: PartialFunction[Int, String] = {
1819
case 1 => "matched by PartialFunction"
1920
}
2021

21-
// Convert an optional function to a pattern
22+
// Define an optional function
2223
val f: Int => Option[String] = { i =>
2324
if (i == 2) {
2425
Some("matched by optional function")
@@ -31,11 +32,11 @@ val f: Int => Option[String] = { i =>
3132
val pf2: PartialFunction[Int, String] = f.unlift
3233

3334
util.Random.nextInt(4) match {
34-
case pf.extract(m) =>
35+
case pf.extract(m) => // Convert a PartialFunction to a pattern
3536
println(m)
36-
case f.extract(m) =>
37+
case f.extract(m) => // Convert an optional function to a pattern
3738
println(m)
38-
case pf2.extract(m) =>
39+
case pf2.extract(m) => // Convert a PartialFunction to a pattern
3940
throw new AssertionError("This case should never occur because it has the same condition as `f.extract`.")
4041
case _ =>
4142
println("Not matched")

0 commit comments

Comments
 (0)