[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01902] Re: Enumerations and all that.

From: Dave Thomas <Dave@...>
Date: 2000-03-16 16:53:29 UTC
List: ruby-talk #1902
Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:

> Thank you to the people who responded to my questions about
> Enumerated types.  I have put something together that does what I
> want now, and have some code to (not rigorously) test it.  It may
> have major weaknesses that I have not seen, so I would welcome
> comments on it.

I was wondering: if, rather than making each enumeration an instance,
you were instead to define a new class for it (probably itself a
subclass of Enumeration), then there'd be no need for the rest of the
user-level code to keep an object reference lying around. You could
say something like

   Enumeration.create("Colours", { RED => 1, GREEN => 2, ... })

and then elsewhere in the code simply reference

    Colours::RED
    Colours::GREEN

and so on.

If you wanted to go that route, the method Module#const_set would be
useful.

Regards


Dave

In This Thread