Re: enums 1.0 library / gem - safe enumeration types for ruby e.g. enum :Color, [:red, :green, :blue]

Gerald Bauer <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAAxEZd9YX0=LdriEiN5dt5cGM-KpXHoOFaTZchwOBb+pr7B=uQ@mail.gmail.com>
Hello,

> Is it possible to assign a specific integer values to a symbol? For some
> symbols? Or perhaps all or no symbols?

FYI: The latest (and greatest) enums library v1.3 [1] now supports
assigning your own integer values too. Example:

```
enum :Color, { red:   0,
               green: 1,
               blue:  2 }

enum :FileAttrib, { read_only: 1<<0,    # 2^0 = 1  = 0b00000001
                    hidden:    1<<1,    # 2^1 = 2  = 0b00000010
                    system:    1<<2,    # 2^2 = 4  = 0b00000100
                    archive:   1<<5,    # 2^5 = 32 = 0b00100000
                  },
                  flags: true
```

and so on.

 Happy coding with ruby. Cheers. Prost.

[1] https://github.com/s6ruby/enums

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.