Unexpected use of alias in enums (tip)

Tip on how to use alias to extend enums

Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Unexpected use of alias in enums (tip)

 · 
Posted: 15.10.2014 - 17:15  ·  #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
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Unexpected use of alias in enums (tip)

 · 
Posted: 16.10.2014 - 01:27  ·  #2
Nice find ;-)
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   46   60 · Page-Gen-Time: 0.02502s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI