karelpeeters
02/08/2019, 10:29 AMclass Env {
fun sub() = SubEnv(this)
}
class SubEnv(val parent: Env)
Is there a nice way to make sub() the only possible way to construct a SubEnv instance? Making the constructor of SubEnv private isn't allowed. Making SubEnv an inner class doesn't help either, you're still not allowed to make the constructor private.spand
02/08/2019, 10:36 AMSubEnv an interface or sealed baseclass and make SubEnvImpl privatekarelpeeters
02/08/2019, 10:36 AM