construct block should be used for setting property values init is called before all constructors so is shared by them all
On Wed, 2010-01-06 at 02:17 -0500, Arc Riley wrote: > Why does a class's init method get called before its construct method? > > This seems very counter-intuitive to me given the limitations on the > construct method; > > A *construct* block is used to define a creation method which requires > parameters at construction time when being instantiated via the new > operator. Creation methods are limited to setting the properties of the > class and may perform no other task (an init block should be used to perform > any other type of initialization). A class can have many creation methods > with either different names or different parameters. A default creation > method without any parameters is always available if no explicit creation > method is defined. > > Since init runs first, none of the initialization code has access to > parameters passed to it by the new function. Say, for example, an argument > passed is a parent container for the new instance to add itself to - all the > construct method is allowed to do (if I read this correctly) is set > self._parent which only happens after init has run. > > Am I reading this wrong, or do we need to implement some hacked up delayed > initializer for the mainloop to handle to work around this? > _______________________________________________ > Vala-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/vala-list _______________________________________________ Vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
