newbie style question regarding constants
Martin Drautzburg
martin.drautzburg at web.de
Thu Nov 13 19:43:49 UTC 2003
Ragnar Hojland Espinosa <ragnar at linalco.com> writes:
> I have a method sort of like:
>
> Connection>>login: aUsername credential: aCredential authMethod: anAuthMethod
> "stuff here"
>
> and
>
> AuthMethod class>>METHODSIMPLE
> ^ 16rFFFF
>
> so I do a
>
> conn login: 'me' credential: '' authMethod: (AuthMethod: METHODSIMPLE).
>
> but I was wondering on whether there's a nicer way to store and
> retrieve the authMethod constants.
Shoudn't that be
AuthMethod METHODSIMPLE
(without a colon) ?
I suppose you want to provide a selection of some named AuthMethods, right ?
You could use a symbol (a selector) as in
Connection>>login: aUsername credential: aCredential authMethod: anAuthMethodSelector
|authMethod|
authMethod _ self perform: anAuthMethodSelector
...
Connection>>methodSimple
^ 16rFFFF
and call it as
conn login: 'me' credential: '' authMethod: #methodSimple
The constants would be in Connection then. This assumes that the
constants have no relevance outside of Connection and AuthMethod was
only used to hold the constants.
More information about the Squeak-dev
mailing list
|