Dodo doc > Types > Nested Types

Nested Types

A type declaration can be nested in another type. In that case the nested type is linked to the enclosing type instance which creates it.

The nested type gets a default value only if it has no constructors. If the nested type has constructors, including a no-argument constructor, it does not have a default value. This is because the constructor needs to know the enclosing object before it can run.

In the nested type, declarations of the enclosing type are declared. The "self" variable is a reference to the current nested type instance.


class FoodProcessor:
def SpeedSetting = new Integer
SpeedSetting speed()
Rationale: if the no-argument constructor of nested types was invoked at instance creation, it would make it more complex and slow and could add side effects to an operation which is normally stateless (prototype cloning)

^ 4.3. Use as Prototype

v 4.5. Type Members