[Squeakland] When to define a local variable
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.
On Mar 31, 2007, at 9:58 AM, Young-Jin Lee wrote:
> 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
More information about the Squeakland