Enums - probably an old subject
Craig Dillabaugh
cdillaba at cg.scs.carleton.ca
Wed Nov 20 23:28:13 PST 2013
On Thursday, 21 November 2013 at 07:22:39 UTC, Steve Teale wrote:
> import std.stdio;
>
> enum Intention
> {
> EVIL,
> NEUTRAL,
> GOOD,
> SAINTLY
> }
>
> void foo(Intention rth)
> {
> if (rth == EVIL)
> writeln("Road to hell");
> }
>
>
> void main()
> {
> foo(EVIL);
> }
>
>
> Why does the compiler complain in both places about EVIL. Can
> it not work out which EVIL I mean? There's only one choice.
That should be:
if( rth == Intention.EVIL ) and
foo( Intention.EVIL );
More information about the Digitalmars-d
mailing list