| Thread overview | ||||||
|---|---|---|---|---|---|---|
  | 
May 10, 2011 string[] enumerations | ||||
|---|---|---|---|---|
  | ||||
Hi there,
I need enumerations with string[] as base type. It works when I use
enum MyEnum : string[] {
 a = ["a", "b", "c"],
}
but when I add more types like
enum MyEnum : string[] {
 a = ["a", "b", "c"],
 b = ["d", "e", "f"],
 c = ["g", "h", "i"], // ...
}
I always get the following error(s):
Error: Integer constant expression expected instead of ["a", "b", "c"] < ["a", "b", "c"]
Is there any solution in D to realize to add more than one string[]- array to an enumeration?
Thanks!
 | ||||
May 10, 2011 Re: string[] enumerations | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Nrgyzer  | I've ran into the same problem. There's a way to partially simulate an enum with a struct and some typedef magic: http://codepad.org/RNYyyFqc So it kind of acts like an enum. But it's just a workaround, there might be performance issues + switches don't work for structs. It was just an experiment though.  | |||
May 10, 2011 Re: string[] enumerations | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Nrgyzer  | Nrgyzer napisał: > I need enumerations with string[] as base type. What for? -- Tomek  | |||
May 11, 2011 Re: string[] enumerations | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Andrej Mitrovic  | == Auszug aus Andrej Mitrovic (andrej.mitrovich@gmail.com)'s Artikel
> I've ran into the same problem.
> There's a way to partially simulate an enum with a struct and some
> typedef magic: http://codepad.org/RNYyyFqc
> So it kind of acts like an enum. But it's just a workaround, there
> might be performance issues + switches don't work for structs. It was
> just an experiment though.
Works great - thanks!
 | |||
Copyright © 1999-2021 by the D Language Foundation
 
Permalink
Reply