From: Andreas Habel Date: 2005-05-03T03:09:28+09:00 Subject: Re: enum in ruby ? Andreas Schwarz wrote: > Andreas Habel wrote: > >> Hi, >> >> I`ve a simple question about constants in ruby. Is there a possibility >> to define constants in a module or a class like a enum in c? >> >> Maybe something short like the 'attr_accessor' syntax would be great! >> >> class MyClass >> const_def :CONST_A1, :CONST_A2, :CONST_A3 >> const_def :CONST_B1, :CONST_B2, :CONST_B3 >> end > > > What do you need constants for; why not directly use symbols? I have to synchronize a lot of constants in my code with "constants" in a database which were generated using a sequence. With the enum function I don`t have to matter which value the constant has in my database nor in ruby. Only the order is important. Or has someone a better suggestion for that ?