In Java, we have the package protected (default) modifier for classes, which allows us to have many classes in a single package but exposes only a few and keeps the logic encapsulated.
对于Kotlin 来说,情况似乎并非如此.如果我想让几个类彼此可见,但不能再进一步,我必须使用私有修饰符来限制单个文件的可见性.
So if you want 10 classes in a package but only one of them to be public, you'd have to have one huge file with all the classes in it (and private
all over the place).
这是正常的做法还是有办法在Kotlin中实现类似的模块化?
我不明白:如果他们有包的概念,为什么他们要取消包保护访问呢?
Update: We might have package protected visibility after all
see the discussion here
Update: If you read through the discussion and still think this is a must-have feature for the language, please vote here