Tagged Questions

A data type consisting of a set of named values called elements, members or enumerators of the type.

learn more… | top users | synonyms

2
votes
2answers
90 views

How can an Enumeration with Descriptions be cast into a Dictionary?

The Enumeration in question is based on int, so the following Extension returns a Dictionary<int, string> of the Enum's Value and Description. Is there a cleaner way of implementing this? ...
8
votes
4answers
183 views

Boolean enums: improved clarity or just overkill?

Suppose we are writing a GUI toolkit in C++ (though this question may also apply to other languages). We have a button class with a member function hide, which hides the button. This member function ...
1
vote
2answers
376 views

Boolean flags encoded as integer implemented with EnumSet

I'm a beginner in Java so I would appreciate a review of following simple class - in fact it's my first real usage of enums. The background: I'm parsing MySQL internal client-server protocol. One of ...
5
votes
3answers
329 views

Enum vs int wrapper struct

I am writing code that has objects having integer member variables where the integer value has a specific constant meaning, which normally means "use an enum". Suppose the values are the days of the ...
2
votes
1answer
87 views

Scala Direction enum with Enumeration and collection usage

I've just implement direction enum object Direction extends Enumeration { type Direction = Value val Up, Right, Down, Left = Value val pairs = HashSet() ++ List((HashSet() ++ List(Up, Down)), ...
4
votes
1answer
635 views

Getting the value of a custom attribute from an enum

Suppose we have an enum called "Planet" and it has a custom attribute of class "PlanetAttr", these methods will give you the attribute value for a given Planet value: private static PlanetAttr ...