Newbie question
subbukk
subbukk at gmail.com
Mon Jul 23 17:50:19 UTC 2007
On Monday 23 July 2007 8:02 pm, Richard Eng wrote:
> Thanks! I didn't know about the period.
It is one of those dark little secrets in Smalltalk :-). Unlike other
Smalltalk expressions, it doesn't follow the "<receiver> <message>" pattern.
b := { x+1.x+2.x+3}.
is equivalent to:
b := Array new: 3.
b at: 1 put: x+1.
b at: 2 put: x+2.
b at: 3 put: x+3.
The period is really a separator and not an operator. Since period is also
used as a decimal point, one needs to watch out for gotchas like:
{1.2.3} = an array with two elements 1.2 and 3
{1 . 2 . 3} = an array with three elements 1, 2 and 3
I wonder how period came to be used as a separator within braces in Smalltalk
instead of comma or semicolon.
Regards .. Subbu
More information about the Squeak-dev
mailing list
|