Using enums as function parameters (in a minimized way)

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 1 03:13:06 PST 2015


V Tue, 01 Dec 2015 10:44:06 +0000
Ozan via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsáno:

> Hi
> 
> Let's say we have an enum like
> 
> enum SomethingAboutChristmas {
>    SantaClaus,
>    Angel,
>    Tree
> }
> 
> and want to use it in a function like
> 
>    void goingChristmas(SomethingAboutChristmas enumvalue)
> 
> it works fine like following
> 
>    goingChristmas(SomethingAboutChristmas.Tree)
> 
> I prefer to use a shorter version
> 
>    goingChristmas(Tree)
> 
> because it's clear (for me), that "Tree" in "goingChristmas()" is 
> an enum of "SomethingAboutChristmas"
> 
> Is any chance to do this? The DMD-compiler says no.
> 
> Thanke & Regards, Ozan
> 

with(SomethingAboutChristmas) {
    goingChristmas(Tree);
    goingChristmas(SantaClaus);
    ...
}



More information about the Digitalmars-d-learn mailing list