Could someone please explain package objects, not so much the concept but their usage.
I've tried to get an example working and the only form I got to work was as follows:
package object investigations {
val PackageObjectVal = "A package object val"
}
package investigations {
object PackageObjectTest {
def main(args: Array[String]) {
println("Referencing a package object val: " + PackageObjectVal)
}
}
}
Observations I've made so far are:
package object _root_ { ... }
is disallowed (which is reasonable),
package object x.y { ... }
is also disallowed.
It seems that a package object must be declared in the immediate parent package and, if written as above, the brace delimited package declaration form is required.
Is anyone using them and, if so how?
Thanks.