[Newbies] Understanding "self"
Andy Burnett
andy.burnett at knowinnovation.com
Wed Jan 30 17:43:42 UTC 2008
I am working through the SBE book ( which is really very good) and I
have been experimenting with using self in blocks.
In simple terms I am doing something like:
" within the initialisation of an object"
aVar := AnotherObj new
aVar setBlockTo: [Transcript show: self]
Then I had a method in the first object which asked the second object
to show the value of its block.
What I was expecting was for self to be defined in terms of the object
it was assigned to ie the second object. However it actually returns
tv details of the object the block was coded in
Somehow I don't think I am explaining myself very well. But what I
want to know is how to think about self. Will it always point to the
object in which the method was actually written?
Thanks
AB
More information about the Beginners
mailing list