scala - What do access modifiers at class/object/trait level mean? -


in scala can add access modifiers class/trait/object, like

private class foo protected[this] trait foo 

i have not found explanation on these class/trait/object-level modifiers. such combinations make sense , mean?

they mean same access modifiers class/trait members, classes , traits can members of other classes. example:

class {     private class foo } 

class foo visible class a. if change modifier private[this], called object private, , foo only visible it's parent instance of a.

declaring private, private[this], protected or protected[this] makes sense within class or trait, because has private something. in case, foo being private a. same applies traits.

we not have containing object, , make them package private.

package com.example.foo  private[foo] class foo 

now class foo visible other members of package com.example.foo.

do make sense? in cases i'm sure useful have private classes , traits within other object.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -