Fun with Literals...
Marcus Denker
denker at iam.unibe.ch
Mon Apr 25 06:50:58 UTC 2005
Literals are fun:
>>>> tt
>>>> 'hello' become: OrderedCollection new.
>>>> 'hello' add: 1.
>>>> 'hello' add: 2.
>>>> ^'hello'.
>>>
>>> Ouahhhhhh
>>> I thought that become: always needed a "variable"
>>> here this means that the literal frame reference is used....
>>> crazy stuff.
>>>
>>
>> hehe, I like this ;-)
>>
>> This method returns the number of times it has been called:
>>
>> tt
>> 'hello' isString ifTrue: ['hello' become: (Array new: 1). ^'hello'
>> at: 1 put: 1].
>> ^'hello' at: 1 put: ('hello' at: 1) + 1.
>>
:-)
Marcus
More information about the Squeak-dev
mailing list
|