在Scala 2.8中打包private修饰符 [英] Package private modifier in Scala 2.8
本文介绍了在Scala 2.8中打包private修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我尝试
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中打包private修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文