Lyle Johnson wrote:
>I checked the FAQ but didn't see this one addressed. Is there any automatic
>way to assign a range of integer values to a set of names, like "enum"
>values in C/C++? The current approach I've taken, which isn't pretty, is
>just:
>
>    ID_FIRST_VALUE = 0
>    ID_SECOND_VALUE = ID_FIRST_VALUE + 1
>    ID_THIRD_VALUE = ID_SECOND_VALUE + 1
>    ... etc. ...
>
>Those aren't the real names of the constants, but you get the idea. The
>problem here is that if I wanted to insert a new name in the middle of the
>list it throws everything off.

I had wondered about this myself. Since you 
asked, I came up with:

==========
$enum_next = 0
def enum
	return ($enum_next += 1)
end



class Xyz
	RED = enum
	BLUE = enum
end

p Xyz::RED
p Xyz::BLUE
==========

Since the numbers are assigned at run-time, not 
compile-time, you will be FORCED to avoid 
counting on the underlying values.

Kevin