For example, in class B I have #setValue
and #getValue
, but I can't use these in Class A. How do I accomplish this?
edit:
what I thought would work would be ClassBInstance setValue:1.
or even ClassB ClassBInstance setValue:1.
but neither do.
create an instance variable in class A say
instanceVariableNames: 'binstance'
in class A create the initialize
method (instance side i.e. not the class side) and ensure the following code snippet is there
super initialize.
...
bInstance := ClassB new.
now anywhere (i.e. in any method) in ClassA use
bInstance setValue: 'whatever'
or
myVar := bInstance getValue
BTW in Smalltalk conventionally set and get is not used ... its simply
setValue is value:
getValue is value
note difference of the :
hope it helps