[Squeakland] When to define a local variable
youngjin.michael at gmail.com
Sat Mar 31 08:58:47 PST 2007
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'.
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'.
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.
More information about the Squeakland