[Newbies] Referencing a variable?
Amir Ansari
fractallyte at csi.com
Thu Dec 3 12:46:21 UTC 2009
Yes! That did it!
First time I've used 'perform:'; I'd never have considered it.
Thank you so much!
Amir
On 3 Dec 2009, at 12:05, Bert Freudenberg wrote:
> On 03.12.2009, at 12:59, Amir Ansari wrote:
>>
>> But I'd like to reuse the code as much as possible, so I'd prefer to
>> do something like this:
>>
>> element := 'title'.
>> choice := myLibrary collect: [:each | each element].
>
> element := #title.
> choice := myLibrary collect: [:each | each perform: element].
>
> Note that this sends the "title" message. There is no way to directly
> access an instance variable from outside the object. Objects in
> Smalltalk are true objects, not data structures. The code above only
> works if you implemented a "title" method that returns the instance
> variable.
>
> - Bert -
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list