logo       

Re: yourself: msg#00264

lang.smalltalk.squeak.beginners

Subject: Re: yourself


On 31.08.2006, at 17:35, Bakki Kudva wrote:

Hi,

I'm a bit confused about y ourself. I understand that the definition
of yourself is ^self
But when I browse Object and look at yourself: all I find is the
description string..
"Answer self."

What happened to ^self? Where is the actual code implementing this?


self is the default return value. So if you return nothing special, the compiler
will add a ^self at the end.

A good rule is to make the ^self explicit as soon as it is important, thus
for our lecture (#yourself is covered in 04:
http://www.iam.unibe.ch/~scg/Teaching/Smalltalk/Slides/04Idioms.pdf )

we changed the implementation of #yourself to be

yourself
"Answer self."
^self

This is in 3.9

Marcus


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise