Unexpected use of alias in enums (tip)

Tip on how to use alias to extend enums

Merlin
Administrator
Avatar
Geschlecht:
Alter: 25
Beiträge: 1474
Dabei seit: 03 / 2005
Betreff:

Unexpected use of alias in enums (tip)

 · 
Gepostet: 15.10.2014 - 17:15 Uhr  ·  #1
I wanted to do something like this

Code
type
TMyType = ( Fred, Joe, Bill, Billy = Bill, Mike );


but the compiler expects numbers after the equals.

Now of course I know I could count the bits and put

Code
type
TMyType = ( Fred, Joe, Bill, Billy = 2, Mike );


but that is not very nice (for lots of reasons). But I tried

Code
type
TMyType = ( Fred, Joe, Bill, Mike );

alias
  Billy = Bill;


and it seems to work, so I thought I would share...
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: Unexpected use of alias in enums (tip)

 · 
Gepostet: 16.10.2014 - 01:27 Uhr  ·  #2
Nice find ;-)
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   46   60 · Page-Gen-Time: 0.030247s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI