class Foo(bar: String) {
import Foo.Bar
def this() = this(Bar) // this line fails, it seems I can only do
// def this() = this(Foo.Bar)
}
object Foo {
val Bar = "Hello Bar"
}
Basically, how do I use Bar after I import Foo.Bar, do I really have to call Foo.Bar every single time?
Secondary constructors have outer scope to prevent you doing something silly like this:
where you try to pass a parameter to the constructor…after creating it in the constructor.
Unfortunately, this means that
import Foo.Baris not in scope for that line. You’ll have to use the full pathFoo.Bar.For everything in the class except the additional constructors,
Foo.Barwill be in scope asBar.