![]() |
![]() |
![]() |
![]() |
![]() |
|
The first time a demonstration instance is sent
a commonValue message, that commonValue method creates a new
value holder and answers that value holder; whenever the same demonstration instance receives another
commonValue message, that commonValue message answers the
same value holder previously created:
ValueHolderDemo... method definition instance commonValue ^ commonValue isNil ifTrue: [commonValue := 0 asValue] ifFalse: [commonValue]
As indicated, the commonValue method creates a new value holder by
sending the asValue message to a receiver, which not only
creates a value holder, but also initializes that value holder. In this
example, the initial value of the value instance variable is the
integer 0.