在 Scala 2.8 中打包私有修饰符 [英] Package private modifier in Scala 2.8
本文介绍了在 Scala 2.8 中打包私有修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我尝试
private[com.company.foo] def bar(xml: XmlPath) = {
我明白了
[error] ... ']' expected but '.' found.
[error] private[com.
[error] ^
那是怎么回事?我只能将它设为 com.* 的包私有,还是...?
What's with that? I can only make it package-private to com.*, or...?
推荐答案
你只能定义封闭包,在里面定义代码:
You can only define the enclosing package, within which the code is defined:
package com.company.foo
class Bar{
private[foo] def bar(xml: XmlPath)
}
如果您想将其设置为公司:
and if you want to set it to company:
private[company] def bar(xml: XmlPath)
这篇关于在 Scala 2.8 中打包私有修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文