digitalmars.D.learn - Extend Enum
- Mars (9/25) Jan 23 2012 Hello everybody.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (16/40) Jan 23 2012 If it makes sense, you can use version(x) blocks within the single enum
- Mars (4/7) Jan 23 2012 Could you give me an example, what that would look like? So far I
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (3/9) Jan 23 2012 Me neither. Sorry for the noise. :(
Hello everybody. I'd like to know if there's a way, to extend an Enum, based on version(). I have an Enum, that holds various values, but some are different, in other versions. So the alternative would be to define the Enum several times.version(x) { enum example { FOO = 1, BAR = 2, } } else { enum example { FOO = 1, BAR = 3, } }Is there a better way to do this? Maybe a class with static consts...? How should I do it? Mars
Jan 23 2012
On 01/23/2012 02:38 PM, Mars wrote:Hello everybody. I'd like to know if there's a way, to extend an Enum, based on version(). I have an Enum, that holds various values, but some are different, in other versions. So the alternative would be to define the Enum several times.If it makes sense, you can use version(x) blocks within the single enum definition, as opposed to putting version(x) outside. Alternatively, it may make sense to define the enum value(s) outside to keep the definition of 'example' relatively clean: version(x) { enum BAR_VALUE = 2; } else { enum BAR_VALUE = 3; } enum example { FOO = 1, BAR = BAR_VALUE, } Aliversion(x) { enum example { FOO = 1, BAR = 2, } } else { enum example { FOO = 1, BAR = 3, } }Is there a better way to do this? Maybe a class with static consts...? How should I do it? Mars
Jan 23 2012
On Monday, 23 January 2012 at 22:48:02 UTC, Ali Çehreli wrote:If it makes sense, you can use version(x) blocks within the single enum definition, as opposed to putting version(x) outside.Could you give me an example, what that would look like? So far I couldn't find a way to use version inside an Enum. Mars
Jan 23 2012
On 01/23/2012 04:04 PM, Mars wrote:On Monday, 23 January 2012 at 22:48:02 UTC, Ali Çehreli wrote:Me neither. Sorry for the noise. :( AliIf it makes sense, you can use version(x) blocks within the single enum definition, as opposed to putting version(x) outside.Could you give me an example, what that would look like? So far I couldn't find a way to use version inside an Enum. Mars
Jan 23 2012