Reputation: 481
Is there an access modifier [Edit: or an idiomatic workaround which achieves the same thing] which will allow a Scala name/object to be visible to all the code in the same file, but not the whole package the file is part of?
package org.example.foo
private object SharedStuff {
val bar = 0
}
class Foo {
def apply(x: Int): String = ... something involving SharedStuff.bar ...
}
class Fuz {
def fuzz(t: String): Int = ... something else involving SharedStuff.bar ...
}
In its current state, the object SharedStuff
will be visible to all code in package foo
. I'd like it to be visible to the classes Foo
and Fuz
only, without making an explicit subpackage to enclose this file.
Upvotes: 3
Views: 855