“私有[语法]"在斯卡拉 [英] "private[syntax]" in Scala
本文介绍了“私有[语法]"在斯卡拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个私有[语法]"语言特性是什么?
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)
////
}
^ 位置:scalaz-series-7.3.x/core/src/main/scala/scalaz/syntax/ShowSyntax.scala
^ Location: scalaz-series-7.3.x/core/src/main/scala/scalaz/syntax/ShowSyntax.scala
推荐答案
private[packageX]
表示以下方法/类/对象/构造函数只能从该包内访问 - 在这种情况下 syntax
是包名,这个构造函数只能从 syntax
包内的其他代码访问.
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.
这篇关于“私有[语法]"在斯卡拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文