Hi, SomeClass and SubClass are two different objects. Based on your setup, if you do not call any initialize method, initially calling both "SomeClass isOk" and "SubClass isOk" should return nil.
Running "SomeClass initialize" initializes only the SomeClass object. So now "SomeClass isOk" returns true and "SubClass isOk" returns nil, as its another object that has not been initialized. You get the same behaviour if you first call "SubClass initialize". Now "SomeClass isOk" returns nil because you did not initialize the SomeClass object, but the SubClass. Even if you add initialize in the SubClass class and call it first "SomeClass isOk" will still return false. SomeClass and SubClass are just two different objects of types SomeClass class and SubClass class. It's the same behaviour that you get when you create two instances of these classes. Just because you create an instance of the type SubClass and call super initialize, it doesn't mean that another instance of SomeClass will be initialized. Hope this makes sense/answers your question. Cheers, Andrei On Wed, Apr 29, 2015 at 2:25 PM, Jan Blizničenko <blizn...@fit.cvut.cz> wrote: > Hello > > It seems I misunderstood some concept of classes in Pharo. My problem is > following: > Let's say I have class named SomeClass (subclass of Object) and class named > SubClass (subclass of SomeClass). > > If I create instance variable on SomeClass and SomeClass>>#initialize which > initializes the variable, it gets initialized also when SubClass instance > is > created. > > Now I'm trying to do something similar for class-side variables, but with > no > success. > If I create class-side variable on SomeClass and SomeClass > class>>#initialize which initializes the variable, it gets initialized only > in SomeClass class, but not in SubClass class. > > What I mean: > > Object subclass: #SomeClass > > SomeClass class > instanceVariableNames: 'Ok' > > SomeClass class>>#initialize > super initialize. > Ok := true > > SomeClass class>>#isOk > ^ Ok > > SomeClass subclass: #SubClass > > calling "SomeClass isOk" returns true. > calling "SubClass isOk" returns nil. > > > now If I create method > > SubClass class>>#initialize > super initialize. > > SubClass initializes as I would expect from my experience with instance > initialization, so "SubClass isOk" now returns true. > > > I will appreciate any help. > > Jan > > > > -- > View this message in context: > http://forum.world.st/class-initialization-and-class-side-variables-tp4822869.html > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. > >