Skip to content

Commit 86c4df2

Browse files
author
vitojeng
committed
fix some errors in sample code
1 parent 09e7f2f commit 86c4df2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

_posts/2020-11-06-explicit-term-inference-in-scala-3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ The second step was to define the extension method which relies on two implicits
370370
```scala
371371
// ShowOps.scala
372372
object ShowOps {
373-
implicit class showOps[A](in: A) extends AnyVal {
373+
implicit class showOps[A](private val in: A) extends AnyVal {
374374
def show(implicit instance: Show[A]): String =
375375
instance.show(in)
376376
}
@@ -386,7 +386,7 @@ object Show {
386386

387387
// Either this or import ShowOps and use context bound
388388
implicit def showList[A](ls: List[A])(implicit instance: Show[A]) =
389-
ls.map(instance.show).mkList(",")
389+
ls.map(instance.show).mkString(",")
390390
}
391391
```
392392
which brings us to the main definition:
@@ -399,7 +399,7 @@ case class Mountain(name: String, height: Int)
399399

400400
object Main extends App {
401401
implicit val mountainShow: Show[Mountain] =
402-
Show.fromFunction((m: Mountain) => s"The ${m.name} is ${m.height} meters high")
402+
Show.from((m: Mountain) => s"The ${m.name} is ${m.height} meters high")
403403

404404
val mountains = List(Mountain("Mont Blanc", 4808), Mountain("Matterhon", 4478))
405405
println(mountains.show)

0 commit comments

Comments
 (0)