Look at this example:
class Outer(private val handler: Actor){
def this() = this(new Handler) // type Handler not found ? ?
class Handler extends Actor{
override def act() {
}
}
}
The compiler complain that class Handler is not found. Is this a bug ?
The inner class
Handlerhas a reference on the outer class instance, and you’re trying to create anew Handlerbefore the outer instance exists — which is impossible.You can try something like this instead:
If you’re worried about using
null, you can use the solution described here to replacenullin default values for parameters.