Make your own object initialization

From Cuis CookBook
Jump to navigation Jump to search
  • STARTED
  • How do you make a new object instance ? Usually you call new.
  • If you don't define new yourself and no other superclasses will, new will be found in the Behavior class where there is also basicNew, let's see it
Behavior >> new
	"Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable."
	^ self basicNew initialize
  • So, ignoring indexable variables (vectors and the likes) new calls basicNew and the calls initialize
  • basicNew calls primitive <70>, so that is the end of the story, the ball now it to the VM.
  • After that the balls passes to initialize, here again, if you defined it yoursef ...