[Newbies] invoking a *class* method from a workspace
subbukk
subbukk at gmail.com
Sun May 27 15:14:04 UTC 2007
On Saturday 26 May 2007 10:02 pm, mstram wrote:
> 2) At least one difference I've found is that I when tried to create a
> "class" method that accessed an instance variable, Squeak warned that the
> variable didn't exist and asked if I wante to create it (is this a bug?)
> ... even though it was "declared" in the class definition.
Mike,
Think of instantiation and declaration as being like icecream and its récipé.
You can make many cups of icecreams from the same récipé. The instance
variable (cherry) declared in the class definition (récipé) will be created
only when a object of this class is created (icecream pie). You cannot assign
to an instance variable in a class method anymore than you can eat cherries
from a récipé :-). You 'browse' a récipé and 'inspect' or 'explore' the
icecream :-).
This analogy doesn't apply exactly to Squeak. Since classes are also objects
that are created when you 'accept' the definition (except that its variables
are created from classVariableNames), so you can use them in class methods
immediately. Like Bert explained in an earlier mail, use of classVariables is
very rare.
Enjoy .. Subbu
More information about the Beginners
mailing list