[Squeakland] When to define a local variable

Scott Wallace scott.wallace at squeakland.org
Sat Mar 31 13:46:16 PST 2007

Hi, Young-Jin Lee,

Your guess is exactly correct.  Workspaces assume that any otherwise- 
unknown variable is intended to be a "workspace" variable.


   -- Scott

On Mar 31, 2007, at 9:58 AM, Young-Jin Lee wrote:

> Hi,
> I am a newbie trying to learn Squeak.
> The squeak book and tutorials says that I need to define a local
> variable using a pipe like below:
> | someMuppet |
> someMuppet := Muppet new.
> someMuppet name: 'Elmo'.
> someMuppet greet.
> But when I tried the same code without defining a local variable shown
> below, I got the expected results, which makes me wonder when I should
> define a local variable.
> anotherMuppet := Muppet new.
> anotherMuppet name: 'Gookie Monster'.
> anotherMuppet greet.
> My guess is that I need not define a local variable if my code is
> being executed within a Workspace because all variables such as
> anotherMuppet will have "Workspace" scope.
> Can anyone please explain in more detail about variable scopes?
> Thanks in advance.
> Young-Jin Lee
> _______________________________________________
> Squeakland mailing list
> Squeakland at squeakland.org
> http://squeakland.org/mailman/listinfo/squeakland

More information about the Squeakland mailing list