[Newbies] Where to 'declare' symbols

John Almberg jalmberg at identry.com
Tue Aug 14 12:30:01 UTC 2007


Hi Matthew,

Oh, duh! A method that simply returns a value *is* a simple solution.  
Thanks.

I just tried the class variable approach, too, (just to see how it  
works). It took me a while to figure out what you meant by  
initializing the Class but finally realized the only way to access  
the class variable was to do something like

MyClass initialize.
MyClass MySpecialConstant.

I guess inside a class method, you could access it like:

testValue > MySpecialConstant

Okay, I think I get it.

Thanks!

-- John


> "First, and simplest, implement a message that returns the
> constant:"
>
> MyClass >> mySpecialNumber
>     ^ 5



> "Second, use a class pool variable:"
>
> Object subclass: #MyClass
>     instanceVariableNames: ''
>     classVariableNames: 'MySpecialConstant'
>     poolDictionaries: ''
>     category: 'MyCategory'
>
> "Set its value in the CLASS-SIDE initialize method:"
>
> MyClass class >> initialize
>     MySpecialConstant := 5
>
> "Don't forget to call MyClass initialize. Monticello will
> automatically do this ONCE"
>
> MyClass initialize



>
> -- 
> Matthew Fulmer -- http://mtfulmer.wordpress.com/
> Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Websites for On-line Collectible Dealers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Identry, LLC
John Almberg
(631) 546-5079
jalmberg at identry.com
www.identry.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




More information about the Beginners mailing list