Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"private[syntax]" in Scala [duplicate]

What is this "private[syntax]" language feature?

/** Wraps a value `self` and provides methods related to `Show` */
final class ShowOps[F] private[syntax](val self: F)(implicit val F: Show[F]) extends Ops[F] {
  ////
  final def show: Cord = F.show(self)
  final def shows: String = F.shows(self)
  final def print: Unit = Console.print(shows)
  final def println: Unit = Console.println(shows)
  ////
}

^ Location: scalaz-series-7.3.x/core/src/main/scala/scalaz/syntax/ShowSyntax.scala

like image 350
Michael Lafayette Avatar asked Dec 25 '22 08:12

Michael Lafayette


1 Answers

private[packageX] means the following method/class/object/constructor is accessible only from within that package - in this case syntax is the package name, and this constructor is only accessible from other code inside syntax package.

like image 72
Tzach Zohar Avatar answered Jan 02 '23 21:01

Tzach Zohar