Reputation: 1015
How do you make a protected function in a class accessible to just all classes in the package in Scala?
Upvotes: 15
Views: 6631
Reputation: 4912
If we pay attention to the distinction between function and method, we can define an object deriving from Function
:
protected[packagename] object fn extends (Int=>Int) {
def apply(n: Int) = 2*n
}
Upvotes: 11