3 Dec 2009 13:05
Re: Referencing a variable?
Bert Freudenberg <bert <at> freudenbergs.de>
2009-12-03 12:05:18 GMT
2009-12-03 12:05:18 GMT
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 -
RSS Feed