Enums - probably an old subject

Steve Teale steve.teale at britseyeview.com
Thu Nov 21 11:01:38 PST 2013


>
> That should be:
>
> if( rth == Intention.EVIL ) and
> foo( Intention.EVIL );

Phobos is less picky than the compiler. Try this:

import std.stdio;

enum Intention
{
    EVIL,
    NEUTRAL,
    GOOD,
    SAINTLY
}

void foo(Intention rth)
{
    if (rth == Intention.EVIL)
       writefln("The road to hell is paved with %s and %d", rth, 
rth);
}


void main()
{
    foo(Intention.EVIL);
}






More information about the Digitalmars-d mailing list