How do I iterate over enum members at runtime?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat Apr 9 18:42:45 PDT 2011
On 4/10/11, Jesse Phillips <jessekphillips+D at gmail.com> wrote:
> Andrej Mitrovic Wrote:
>
>> It's a shame that an enum with a tag doesn't have a .length property.
>> I've had to use __traits to build an array just to get the length.
>
> It has .max
>
> http://www.digitalmars.com/d/2.0/enum.html
>
That doesn't show me the number of values an enum tag has, only its
largest value.
void main()
{
writeln(foo.max); // 101, not 4
}
enum foo : int
{
a,
b,
c = 100,
d
}
More information about the Digitalmars-d-learn
mailing list